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

xsunil kumar

Ranch Hand

Posts: 147

posted 7 years ago

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

Posts: 73

posted 7 years ago

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:

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.