Menu

Unable to send mail due to "java.lang.NoClassDefFoundError: javax/activation/DataSource"

Help
2023-12-24
2024-01-17
  • Aejaz Muslim

    Aejaz Muslim - 2023-12-24

    I am trying out the latest version 2.3.2 on Linux with the following JDK,

    openjdk version "11.0.6" 2020-01-14
    OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
    OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)

    & getting the following exception when JTrac tries to send password via email during new user creation,

    Caused by: java.lang.NoClassDefFoundError: javax/activation/DataSource
    at org.springframework.mail.javamail.JavaMailSenderImpl.createMimeMessage(JavaMailSenderImpl.java:325)
    at info.jtrac.mail.MailSender.sendUserPassword(MailSender.java:265)
    at info.jtrac.JtracImpl.storeUser(JtracImpl.java:498)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at com.sun.proxy.$Proxy8.storeUser(Unknown Source)
    at info.jtrac.wicket.UserFormPage$UserForm.onSubmit(UserFormPage.java:306)
    at org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1384)
    at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:811)
    ... 52 more
    Caused by: java.lang.ClassNotFoundException: javax.activation.DataSource
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 69 more

    **I see that ROOT.war has jakarta.activation-1.2.1.jar which has the class javax.activation.DataSource but somehow it is not getting picked up. I tried putting the old activation-1.1.1.jar in jtrac-2.3.2/lib directory but there is no change in the Exception.

    Please let me know if I need to downgrade Java version or there is an alternative for JDK 11.
    **
    Thanks,
    Aejaz

     
  • Ulf Dittmer

    Ulf Dittmer - 2023-12-27

    JTrac should work fine out of the box on either Java 8 or Java 11. As you found, the class it's complaining about is actually present. Make sure you don't have other jar files containing JavaMail or Activation (which also comes as part of JTrac) anywhere in your classpath (like in your servlet container's shared "lib" folder).

     
  • Aejaz Muslim

    Aejaz Muslim - 2024-01-16

    Tried again on CentOS Linux release 8.4.2105 using jetty included in the JTrac 2.3.2 distribution with,

    • OpenJDK 8
    • Oracle JDK 11.0.21
    • OpenJDK 11.0.6

    But I am getting exactly same exception as mentioned above. I started jetty(i.e. start.sh) from a blank classpath & lib directory of the distribution was unchanged. The required class (javax.activation.DataSource) exists only in ROOT.war(renamed to jtrac.war)/WEB-INF/lib/jakarta.activation-1.2.1.jar

    Please let me know what else to look for & any additional information to investigate this further as it is critical functionality.

    Thanks.

     
  • Ulf Dittmer

    Ulf Dittmer - 2024-01-17

    I was now able to reproduce this problem. The issue is with the lib/mail/javax.mail.glassfish-1.4.1.v201005082020.jar library. If you remove that, email sending should work.

     
  • Ulf Dittmer

    Ulf Dittmer - 2024-01-17

    I have updated the jtrac-2.3.2.zip file so it runs out of the box.

     
  • Aejaz Muslim

    Aejaz Muslim - 2024-01-17

    Thanks a lot. I also found the issue with the bundled mail jar from another source & was able to make it work after removing the jar.

     

Log in to post a comment.

MongoDB Logo MongoDB