Search code examples
javajakarta-mailwindows-server-2012apache-tomeetomee-7

WAR file deployed to TomEE Plus not sending emails: loader constraint violation error


I deployed an EJB application (provided as a .war file) to TomEE Plus 7.1.0.

It runs alright, but it was noticed that emails were not being sent.

I investigated the log file at logs/tomee-stderr.[date].log and found this:

java.lang.LinkageError: loader constraint violation: loader (instance of java/net/URLClassLoader) previously initiated loading for a different type with name "javax/mail/Session"

followed by a very, very long (>500k lines) stack trace.

I found a related question (java.lang.LinkageError: loader constraint violation:previously initiated loading for a different type with name "javax/mail/Session") and it is said the solution consists in marking the dependency to javamail as a "provided" dependency, but my understanding is that this is supposed to be done in the Maven project file, to which I don't have access.

I can edit the contents of the ROOT directory at will (and I tried deleting two files, namely, mail.jar and mail-1.4.4.jar, from the WEB-INF/lib directory, but to no avail); I believe I can also edit the .war file with 7-zip; and finally I can modify any configuration in the server. But I cannot edit the application's source code and/or recompile it.

(As potentially relevant information, I do have read access to the source code, and it does not appear to use Maven - the existence of a .project file suggests it is an Eclipse project.)

A file named geronimo-javamail_1.4_mail-1.9.0-alpha-2.jar is part of TomEE and is located in the lib folder.

Given my constraints (no maven, no compilation - existing WAR file must work), how can this error be solved?

[Edit 1]

  • I removed both mail.jar and mail-1.4.4.jar from the WAR file (with 7-zip) and re-deployed, resetted the log file but the error remains the same.

  • I tried deleting geronimo-javamail_1.4_mail-1.9.0-alpha-2.jar from TomEE's lib folder, but TomEE fails to start.


Solution

  • It seems that there is still a jar file that contains the javax.mail.Session class? Please extract all the WEB-INF/lib to an folder and search for the content of all the jar files if it contains the string "javax/mail/Session"