*
The moose likes Tomcat and the fly likes Mail resource look up failed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Mail resource look up failed " Watch "Mail resource look up failed " New topic
Author

Mail resource look up failed

Alex S.K. Lau
Greenhorn

Joined: Mar 14, 2013
Posts: 2
I have a typical mail resource set up for my Tomcat webapp

context.xml
<Resource name="mail/Session" auth="Container" type="javax.mail.Session" mail.smtp.host="xxx.xx.x.xxx"></Resource>

web.xml
<resource-ref>
<description>Resource reference to a factory for javax.mail.Session instances that may be used for sending electronic mail messages, preconfigured to connect to the appropriate SMTP server.</description>
<res-ref-name>mail/Session</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
</resource-ref>

Servlet code

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
javax.mail.Session msession = (javax.mail.Session) envCtx.lookup("mail/Session");
System.out.println("Email server is " + msession.getProperty("mail.smtp.host"));

This works fine on my development computer with Eclispse but failed once I deployed to the actual server.
with returns an exception: Could not connect to SMTP host: localhost, port: 25

My mail server is is not localhost so I put the pritnln statment to confirm that, and it is actuall localhost. I suspect that the server is totally locked down and firewalled by my IT department. Does any one know what is the context look up port so that I can try to open that port to see if it works.


Thanks,

Alex
 
Don't get me started about those stupid light bulbs.
 
subject: Mail resource look up failed