users@glassfish.java.net

JNDI Problem with defined JNDI name

From: <forums_at_java.net>
Date: Tue, 2 Aug 2011 07:59:10 -0500 (CDT)

Hi,

I have an ear with an ejb part (MyServices.jar) and a web-application part
(MyWebapp.war).

  From my webapp I want to access an ejb in the ejb part but its not working:

In the webapp I have a pojo that does a lookup for the ejb using:

DispatcherServiceLocal dispatcherServiceLocal =(DispatcherServiceLocal)new
InitialContext().lookup("DispatcherServiceLocal");
I am not using the Global JNDI Names, I know, but the ejb is defined using:

@Stateless(name = "DispatcherService", mappedName = "DispatcherServiceLocal")
@LocalBean public DispatcherService implements DispatcherServiceLocal,
DispatcherServiceRemote
DispatcherServiceLocal is defined as @Local

In the log file I see:

... Glassfish-specific (Non-portable) JNDI names for EJB DispatcherService:
[DispatcherServiceLocal, ... ...
But I receive the exception:

Lookup failed for 'DispatcherServiceLocal' in
SerialContext[myEnv={java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.
JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
Why is this happening? I am using the no-args InitialContext and both the
pojo doing the lookup and the ejb are in the same app on the same server.

The problem is that if I use the global JDNI name it works:

java:global/myApp/MyServices/DispatcherService!my.service.dispatcher.interfaces.DispatcherServiceLocal
Can anybody help please? Thanks!

Regards


--
[Message sent by forum member 'MohamzJava']
View Post: http://forums.java.net/node/828572