users@glassfish.java.net

Re: resource injection doesn't seem to be working...

From: Sahoo <Sahoo_at_Sun.COM>
Date: Thu, 19 Jul 2007 14:07:24 +0530

Didn't you mention that the Mail session was defined in the server under
the JNDI name "mail/test/myMailer"? That makes "mail/test/myMailer" the
global JNDI name, right? So you should use mappedName to refer to it.
Have you tried out what I said?

If you want to refer to it using a local name, then you have to
establish an association between the local JNDI name and the global
name. The tutorial must have done that using a sun-*.xml. You can also
do something like this:
@Resource (name="mail/foo", mappedName="mail/test/myMailer")
private Session session;

Now,
new InitialContext().lookup("java:comp/env/mail/foo") returns same
session as new InitialContext().lookup("mail/test/myMailer").

-- Sahoo
glassfish_at_javadesktop.org wrote:
> Hi,
>
> Are you sure?
>
> In my understanding of the whole thing, [b]name[/b] IS the JNDI name in the current environment (java:comp/env...). [b]mappedname[/b] ist the name it is mapped to on the server and is server dependent (which is how it is written in the documentation).
>
> I've looked up the code from the JEE tutorial "The confirmer Example Application" page 1186:
>
> @Resource(name="mail/myMailSession")
> private Session session;
>
> greets
> jeremie
> [Message sent by forum member 'granat' (granat)]
>
> http://forums.java.net/jive/thread.jspa?messageID=227231
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>