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

Reply via email to