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

Mail resource look up failed

Alex S.K. Lau

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

<Resource name="mail/Session" auth="Container" type="javax.mail.Session"""></Resource>

<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>

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(""));

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.


I agree. Here's the link:
subject: Mail resource look up failed
It's not a secret anymore!