Mailing List webobjects-dev@wocommunity.org Message #287
From: René Bock <webobjects-dev@wocommunity.org>
Subject: ERJavaMail.defaultSession, JNDI Contexts and tomcat 9
Date: Fri, 22 Oct 2021 12:53:53 +0000
To: webobjects-dev@wocommunity.org <webobjects-dev@wocommunity.org>
Hi,

we have to deploy an application as a tomcat 9 servlet. My current task is to define the JavaMail session via JNDI contexts.


When setting the property er.javamail.sessionConfigViaJNDI=true  the container wasn't able to start correctly any more.  
I had to restart the tomcat in order to proceed :-(

It turned out, the ERJavaMail initialization stuck at

finishInitialization() -> initializeFrameworkFromSystemProperties() -> setDefaultSession(null)


My first step was to implement a lazy initialization of the ERJavaMail.defaultSession.

Now the app started, but the first attempt to send a mail results in the following exception:

.... - failed to send mail: javax.mail.Session cannot be cast to javax.mail.Session

WTF?

It turned out, that the javax.mail-1.6.0.jar was present in $CATALINA_HOME/lib _AND_ in MYApp/WEB-INF/lib
instead of being only in in $CATALINA_HOME/lib.


Even if placing the jars at the correct location fixes the root cause of not starting the container, I would opt for an
lazy initialisation of the defaultSession (see https://github.com/wocommunity/wonder/pull/960)


Regards

René




Best regards

René Bock

--
salient GmbH, Lindleystraße 12, 60314 Frankfurt
Main: +49 69 65 00 96 0  |  http://www.salient-doremus.de

Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to Listmaster