users@glassfish.java.net

Re: java:comp/env problems

From: <glassfish_at_javadesktop.org>
Date: Sat, 08 Mar 2008 14:01:12 PST

Hi,

I just tried something similar:
My own StringFactory (the manorrock thing wasn't downloadable anymore) binds a String to the JNDI and I'm trying to lookup this String from an EJB.

Doing that the classic way via InitialContext.doLookup(...) works, so the StringFactory seems to be alright.

Trying to do the same thing with a Resource annotation doesn't work:
  @Resource(mappedName="StringFactoryTest")
  private String testref = null;

When deploying this, Glassfish logs "This bean [StringFactoryTestBean] has no resource reference by the name of [testref]".
The field "testref" always contains null.

And now things are getting weird:
After hours of trial and error I found out that after changing the field's type to "DataSource" the deployment error message disappears! And indeed the server seems to do a lookup then because as soon as you call the EJB, Glassfish logs the message "Can not set javax.sql.DataSource field de.snowbird.test.StringFactoryManagerBean.testref to java.lang.String".

So obviously the lookup is done in that case.

To me this seems to be a bug in Glassfish!

Norbert
[Message sent by forum member 'realsnowbird' (realsnowbird)]

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