users@glassfish.java.net

Re: Problem on configuring Java Mail Session

From: Sahoo <Sahoo_at_Sun.COM>
Date: Tue, 11 Mar 2008 22:12:34 +0530

If @Resource (name="mail/myMail") was successfully injected, then you
should look up the resource in "java:comp/env" namespace as shown below:

new InitialContext().lookup("java:comp/env/mail/myMail");


Thanks,
Sahoo
glassfish_at_javadesktop.org wrote:
> The Java Mail session created on Glassfish works well if it is injected as @Resource (name="mail/myMail"), but it fails on direct using JNDI as following,
> ...
> InitialContext ctx = new InitialContext();
> Session session = (Session)ctx.lookup("mail/myMail");
> ...
> the exceptioin is exactly the same as the spring case. MailConfiguration can not be cast to MailSession etc. Can someone give some lights on this?
> [Message sent by forum member 'dabaner' (dabaner)]
>
> http://forums.java.net/jive/thread.jspa?messageID=263316
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>