Reputation: 1567
I am facing stackoverflow error when I inject ejb using @EJB or JNDI lookup using InitialContext. Can anybody share kow to inject/lookup EJB from SevletContextListener in JBoss AS 6.
Thanks!
Upvotes: 0
Views: 69
Reputation: 3500
For lookup, you can do something similar to this
InitialContext ctx =new InitialContext();
EjbServiceInterface service= (EjbServiceInterface) ctx.lookup("java:global/earName/ejbJarName/EjbServiceInterfaceImpl!com.example.EjbServiceInterface");
In this example, EjbServiceInterface is a remote interface for EjbServiceInterfaceImpl, which implements the ejb service.
The jndi string depends on the place where you are doing the lookup.. For a local lookup, you don't have to specify earName and ejbJarName.. I recommend looking in your startup log, where it shows the jndi names available for your ejb, and then select the one you need.
Upvotes: 1