Properties not properly set in tomcat mail session.
posted 7 years ago
I have an anoying problem with tomcat and the use of mail sessions.
I've created a testservlet (MyServlet) in my attempts to narrow down the problem. The problem is that the mail session gotten from the jndi-lookup doesn't get the properties I've set in the server.xml.
Here's my MyServlet:
The output I get when starting the Tomcat server is:
First of all the init()-method seems to be run twice. Which I guess is ok since tomcat is the servlet container and can create as many instances of the servlet it wants. But the second time around the mail session doesn't get the properties I have configured in server.xml. You see that the javax.mail.Session instances are not the same in the two runs. All subsequent lookups for mail/Sesssion retrieves the Session-instance with the wrong (javax.mail.Session@1c1c92b) configuration, hence my application won't be able to use the session to send emails. Any help to understand/solve this problem is very appreciated.
Here's the relevent stuff from my server.xml:
And here's the resource-ref in the web.xml:
Cheers /Anders [ November 06, 2008: Message edited by: Anders Lund�n ]