users@glassfish.java.net

Re: JNDI resource ref for MBean ?

From: <glassfish_at_javadesktop.org>
Date: Thu, 21 Feb 2008 02:33:00 PST

I faced the same issue. Now I have the following settings in my project.

In web-xml:

    <resource-ref>
        <res-ref-name>mail/testSession</res-ref-name>
        <res-type>javax.mail.Session</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>

In sun-web.xml:

  <resource-ref>
    <res-ref-name>mail/testSession</res-ref-name>
    <jndi-name>testSession</jndi-name>
  </resource-ref>

In source code:

  Context ic = new InitialContext();
  Session session = (Session)ic.lookup("java:comp/env/mail/testSession");

...and now everything works.

It seems to be important: just "testSession" as JNDI, "mail/testSession" as resource name and "java:comp/env/mail/testSession" for lookup.
[Message sent by forum member 'ardolynk' (ardolynk)]

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