*
The moose likes EJB and other Java EE Technologies and the fly likes how to access one ejb with local interface from different application deployed in same server. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "how to access one ejb with local interface from different application deployed in same server." Watch "how to access one ejb with local interface from different application deployed in same server." New topic
Author

how to access one ejb with local interface from different application deployed in same server.

xsunil kumar
Ranch Hand

Joined: Dec 14, 2009
Posts: 133
Hi, I am using EJB 3 with annotation. I have one local interface and bean class. I want to access this EJB in different application which is deployed in same application server. When i am using

@EJB
public TestEjbInterface testInterface

in any servlet or any EJB session bean from different applicaiton, i am able to get the values but when i am trying to do JNDI look up in POJO class to get TestEjbInterface i am getting Naming exception. I cannot do dependency injection in POJO class as POJO class is not managed by the server.

What is the way to get local ejb which is running in different applicatioin in same applicaiton server in POJO class. If i am using remote interface, i am able to do jndi names.
I am using glassfish application server.

If local interface EJB is not accessible outside the application , then why i am able to get this by using Dependency injection in some servlet or EJB , which are in diff. applicaiton.

Please help me.

Sunil
Pallav Bora
Ranch Hand

Joined: Oct 13, 2009
Posts: 73
In general the following steps should solve your problems (the actual steps may differ from application server to application server).

1. Define the JNDI name in a scope that includes both the application. For example define the JNDI at a Server, Node or cell level.

2. Use fully qualified name to look up the JNDI , starting with cell . For example:

initialContext.lookup(cell/nodes/YourNode/servers/YourServer/com/YourEjb)


Hope this helps
xsunil kumar
Ranch Hand

Joined: Dec 14, 2009
Posts: 133
Thanks Pallav, but still it is not clear to me. Can you give me some sample example or how to define global JNDI names and where.
My another doubt is that , as per my understanding local interface ejb should not be accessible out side of the applicaiton, then how i am able to access this ejb in differnet application using dependency injection.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to access one ejb with local interface from different application deployed in same server.