users@glassfish.java.net

Re: JNDI resource ref for MBean ?

From: <glassfish_at_javadesktop.org>
Date: Thu, 17 Jan 2008 02:43:38 PST

> Seen the same problem right now following my way
> through the glassfish JavaMail tutorial[1], trying to
> access a JavaMail session configured in glassfish
> V2u1 in order to fetch messages from an IMAP spool...
> :(

To add to this, I am not sure whether or not I am a victim of some JNDI weirdness or just too stupid to do it right:

- The behaviour stated above is caused by the following code in my Session Bean:

            InitialContext ic = new InitialContext();
            String snName = "mail/LocalIMAP";
            
            Session session = (Session)ic.lookup(snName);

- JavaMail resource configuration does have the JNDI name "mail/LocalIMAP" according to the hints given in Sun AppServer admin guide.

- Using anything prefaced with "java:" as JNDI name, like

String snName = "java:comp/env/mail/LocalIMAP"; or
String snName = "java:mail/LocalIMAP";

as pointed out in the tutorial will end up reproducibly in

javax.naming.NameNotFoundException: No object bound to name java:comp/env/mail/LocalIMAP


Well... Can someone enlighten me about that?
TIA and best regards,
Kristian
[Message sent by forum member 'kawazu' (kawazu)]

http://forums.java.net/jive/thread.jspa?messageID=254389