Hi everybody,
I'm trying to invoke a Stateless Session Bean (EJB3) from a helper class (POJO) present in the same EJB module, deployed in Glassfish V2. Using Netbeans facilities, it added a private method in my helper class:
private DiaUtilLocal lookupDiaUtilBsn() {
try {
Context c = new InitialContext();
return (DiaUtilLocal) c.lookup("java:comp/env/DiaUtilBsn");
}
catch (NamingException ne) {
throw new RuntimeException(ne);
}
}
When I invoke this method the following error ocurrs:
javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: java.lang.RuntimeException: javax.naming.NameNotFoundException: No object bound to name java:comp/env/DiaUtilBsn
java.lang.RuntimeException: javax.naming.NameNotFoundException: No object bound to name java:comp/env/DiaUtilBsn
Since It isn't possible to use annotations in helper classes, I'm not using @EJB, but trying to invoke the EJB through JNDI reference. I don't know why, but this reference seems to be wrong.
The curious thing it that I'm using exactly the same JNDI reference to invoke the same EJB in a web application. So, a local interface works fine in a web application deployed in the same .ear. Why can't I use the same JNDI reference inside of the EJB module? What should I do to make it happen?
I tested the application with Jboss, just changing the JNDI reference to: <AppName>/DiaUtilBsn/local . It worked fine within the EJB module and also within the WEB module. It makes sense for me.
Any help will be very appreciated. Thank you in advance.
Hildeberto
[Message sent by forum member 'hbeto' (hbeto)]
http://forums.java.net/jive/thread.jspa?messageID=274287