GeeCON Prague 2014*
The moose likes Tomcat and the fly likes Properties not properly set in tomcat mail session. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Tomcat
Bookmark "Properties not properly set in tomcat mail session." Watch "Properties not properly set in tomcat mail session." New topic
Author

Properties not properly set in tomcat mail session.

Anders Lunden
Greenhorn

Joined: Jan 07, 2008
Posts: 12
Hi!

I have an anoying problem with tomcat and the use of mail sessions.

I've created a test servlet (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 ]
Anders Lunden
Greenhorn

Joined: Jan 07, 2008
Posts: 12
I forgot to mention that I'm using Tomcat 5.5.17.

/Anders
 
GeeCON Prague 2014
 
subject: Properties not properly set in tomcat mail session.