users@glassfish.java.net

JNDI lookup problem after migration from JBoss

From: <glassfish_at_javadesktop.org>
Date: Thu, 31 Jul 2008 01:56:18 PDT

Hello,

I'm migrating a EJB3 enterprise project from JBoss to Glassfish and I have problems with the JNDI lookups.

I read the migration FAQs and articles so I changed the JNDI lookups to use the names used in Glassfish.

For example:

My Bean is stated as follows:

@Stateless(name="ContentFetcherBean")
public class ContentFetcherBean implements ContentFetcherLocal {
...

And for the lookup I use:

Context c = new InitialContext();
ContentFetcherLocal cf = (ContentFetcherLocal) c.lookup("java:comp/env/ContentFetcherBean");

I get the error
javax.naming.NameNotFoundException: No object bound to name java:comp/env/ContentFetcherBean

So it looks like it can't resolve the name. Did I do something wrong with the naming? I'm not familiar with Glassfish. When I need references in other beans or in servlets Dependency Injection with the @EJB annotation does work! So the beans are definitely there and deployed correctly. However, I still need a reference from within some helper classes where JNDI lookup is the only possibility I guess.

I don't know if it can be an issue, but in the project packaging we package the business interfaces of all our beans in a seperate jar to reduce dependencies. We package this jar within the ear as a shared lib. This wasn't a problem in JBoss so I don't know if it is an issue here?

Thanks in advance for any help!
[Message sent by forum member 'tverbele' (tverbele)]

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