Search code examples
javajava-8jakarta-mailnoclassdeffounderror

java.lang.ClassNotFoundException: com.sun.mail.util.MessageRemovedIOException


While upgrading application from jdk6 to jdk8, we are getting following error on Message msg = new MimeMessage(session);

 SEVERE: Servlet.service() for servlet [default] in context with path [] threw exception [java.lang.reflect.InvocationTargetException] with root cause
java.lang.ClassNotFoundException: com.sun.mail.util.MessageRemovedIOException
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)

Has anyone faced the same or related issue while upgrading their java app ?

EDIT: the same code is working with java6.


Solution

  • You've got a mix of JavaMail classes from different versions of JavaMail in your classpath. What application server are you using and what's in the lib directory of your web application?