title: ClassCastException casting a class instance to its own class because it is in an "unnamed module" with gradel and tomcat
body: <p>There are many similar issues, but none I could find have the class being cast to itself.  We are using a dependency on the webp support from this project:</p>
  <pre><code>implementation &quot;org.sejda.imageio:webp-imageio:0.1.6&quot;
  </code></pre>
  <p>It works fine if we don't try to change the write params, but if we do like this:</p>
  <pre><code>Iterator imageWriters = ImageIO.getImageWritersByFormatName(&quot;webp&quot;);
  ImageWriter writer = (ImageWriter) imageWriters.next();
  
  WebPWriteParam writeParam = new WebPWriteParam(null);
  writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
  writeParam.setCompressionType(writeParam.getCompressionTypes([WebPWriteParam.LOSSY_COMPRESSION]);
  writeParam.setCompressionQuality(0.75f);
  
  baos = new ByteArrayOutputStream();
  ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
  writer.setOutput(ios);
  writer.write(null, new IIOImage(img, null, null), writeParam);
  </code></pre>
  <p>We get this strange exception</p>
  <blockquote>
  <p>java.lang.ClassCastException: class
  com.luciad.imageio.webp.WebPWriteParam cannot be cast to class
  com.luciad.imageio.webp.WebPWriteParam
  (com.luciad.imageio.webp.WebPWriteParam is in unnamed module of loader
  org.apache.catalina.loader.ParallelWebappClassLoader @34282781;
  com.luciad.imageio.webp.WebPWriteParam is in unnamed module of loader
  org.apache.catalina.loader.ParallelWebappClassLoader @238ad8c)    at
  com.luciad.imageio.webp.WebPWriter.write(WebPWriter.java:67)
  ~[webp-imageio-0.1.6.jar:?]   at
  com.XXX.business.util.ImageServices$ImageSaver.run(ImageServices.java:874)
  [rcw-core.jar:?]  at
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
  [?:?]     at
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
  [?:?]     at java.lang.Thread.run(Thread.java:832) [?:?]</p>
  </blockquote>
  <p>I understand class loaders very will, but don't understand how this module concept is not working here.  Can you get me pointed in the right direction?</p>