I log classes when loaded into a separate log file. I am sure classes are loaded from expected jar files The files are 4 times because I have four web applications in the system.
$ grep javax.activation.DataContentHandler classloaded.log [5436.540s][info][class,load] javax.activation.DataContentHandler source: file:/<tomcatPath>/webapps/app1/WEB-INF/lib/activation-1.1.jar [8903.600s][info][class,load] javax.activation.DataContentHandler source: file:/<tomcatPath>/webapps/app2/WEB-INF/lib/activation-1.1.jar [36283.268s][info][class,load] javax.activation.DataContentHandler source: file:/<tomcatPath>/webapps/app3/WEB-INF/lib/activation-1.1.jar [558992.846s][info][class,load] javax.activation.DataContentHandler source: file:/mnt/app/tomcat/webapps/app4/WEB-INF/lib/activation-1.1.jar (0) $ grep com.sun.mail.handlers.text_html classloaded.log [5436.558s][info][class,load] com.sun.mail.handlers.text_html source: file:/<tomcatPath>/webapps/app1/WEB-INF/lib/javax.mail-1.6.2.jar [8903.600s][info][class,load] com.sun.mail.handlers.text_html source: file:/<tomcatPath>/webapps/app2/WEB-INF/lib/javax.mail-1.6.2.jar [36283.283s][info][class,load] com.sun.mail.handlers.text_html source: file:/<tomcatPath>/webapps/app3/WEB-INF/lib/javax.mail-1.6.2.jar [558992.864s][info][class,load] com.sun.mail.handlers.text_html source: file:/<tomcatPath>/webapps/app4/WEB-INF/lib/javax.mail-1.6.2.jar Regards, Zdenek Henek On Wed, May 21, 2025 at 12:44 PM Zdeněk Henek <vrab...@gmail.com> wrote: > Hello, > > I am getting these errors in one of our systems: > > java.lang.ClassCastException: class com.sun.mail.handlers.text_html cannot > be cast to class javax.activation.DataContentHandler > (com.sun.mail.handlers.text_html is in unnamed module of loader > org.apache.catalina.loader.ParallelWebappClassLoader @6c5398e5; > javax.activation.DataContentHandler is in unnamed module of loader > org.apache.catalina.loader.ParallelWebappClassLoader @719f9efd) > at > javax.activation.MailcapCommandMap.getDataContentHandler(MailcapCommandMap.java:596) > at > javax.activation.MailcapCommandMap.createDataContentHandler(MailcapCommandMap.java:550) > at > javax.activation.DataHandler.getDataContentHandler(DataHandler.java:611) > at javax.activation.DataHandler.writeTo(DataHandler.java:315) > at > javax.mail.internet.MimeUtility.getEncoding(MimeUtility.java:340) > at > javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1575) > at > javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2271) > at > javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2231) > at javax.mail.Transport.send(Transport.java:123) > > > The system runs on Apache Tomcat 9.0.102, OpenJDK Runtime Environment > Temurin-21.0.6+7 (build 21.0.6+7-LTS), RHEL 9.5 Linux > > The functionality has a number of threads in the thread pool and only one > of the threads is causing this issue. Other threads are working as expected. > > I am aware of duplicated jar files (even the same jar file version) in > different classloaders or even in the same classloader. I understand the > classes could be in jars with different names. I have tool to review all > jar files and report > jar files having the same classes. > > Classloaders are configured this way: > > current Tomcat classloaders configuration conf/catalina.properties > > > common.loader="${catalina.base}/lib","${catalina.base}/lib/.jar","${catalina.home}/lib","${catalina.home}/lib/.jar" > > server an shared loaders are empty > server.loader= > shared.loader= > > The class com.sun.mail.handlers.text_html is in jar file with name > javax.mail-1.6.2.jar and the javax.activation.DataContentHandler > activation-1.1.jar > Both jars are in webapplication in WEB-INF/lib directory > There is multiple web applications with these jar files, but these jar > files are not in <Tomcat>/lib directory > > The jars are in same war application but in the exception they are in > different ParallelWebappClassLoaders > ParallelWebappClassLoader @6c5398e5 and ParallelWebappClassLoader @719f9efd > > I have run a heap dump of the application and listed all > org.apache.catalina.loader.ParallelWebappClassLoader instances. > There are 8 objects but none has object id 6c5398e5 or 719f9efd . I tried > to search objects using these object ids in MAT, but they are not available > even when I keep unreachable objects. The object ids are the same every > time in the exceptions. > > I don't see any errors in catalina.out or in localhost<timestamp>.log > files, and the above is the only error I get. System runs stable. We don't > use hot redeployment in this server. > > The system CLASSPATH variable is not pointing to any jar files. > > Any idea what is going on here? Why does this happen? > The system with the error is still running. I could collect more > information if needed. > > Thank you. > > Regards, > Zdenek Henek >