Hi
I have 2 Stateless Session Beans (EJB3) packaged independently in their own module jar; deployment to glassfish works fine (verification also). One of the EJB needs to invoke the other.
First EJB name: SessionStoreBean
First EJB mapped-name (global jndi): ejb/SessionStore
declared as:
@Stateless
public class SessionStoreBean implements SessionStore {
In ejb-jar.xml:
<session>
<ejb-name>SessionStoreBean</ejb-name>
<mapped-name>ejb/SessionStore</mapped-name>
<ejb-class>org.limbs.broker.session.SessionStoreBean</ejb-class>
Second EJB name: AuthzManagerBean
Second EJB mapped-name (global jndi): ejb/AuthzManager
Declared as:
@Stateless
public class AuthzManagerBean implements AuthzManager {
In ejb-jar.xml:
<session>
<ejb-name>AuthzManagerBean</ejb-name>
<mapped-name>ejb/AuthzManager</mapped-name>
<ejb-class>org.limbs.broker.authz.AuthzManagerBean</ejb-class>
I can see that names are properly defined in GlassFish through the JNDI Browsing.
Because AuthzManager needs to invoke SessionStore, in the EJB Class, I define the following injection:
@Stateless
public class AuthzManagerBean implements AuthzManager {
@EJB(name="SessionStoreBean")
private SessionStore sessionStore;
but when I try to run it, I get an exception in GlassFish logs:
[#|2007-03-19T17:31:39.608+0100|INFO|sun-appserver-pe9.0|javax.enterprise.system.container.ejb|_ThreadID=42;_ThreadName=p: thread-pool-1; w: 8;|EJB5070: Exception creating stateless session bean : [{0}]
com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref ejb/SessionStore_at_jndi: org.limbs.broker.session.SessionStore_at_null@org.limbs.broker.session.SessionStore_at_Session@null into class org.limbs.broker.authz.AuthzManagerBean
However, I noticed that if I define the injection like:
@Stateless
public class AuthzManagerBean implements AuthzManager {
@EJB(name="SessionStoreBean", mappedName="ejb/SessionStore")
private SessionStore sessionStore;
then everything works fine. Is this the proper way to handle this kind of EJB reference injection?
Thanks for your help
Jean-Noel Colin
[Message sent by forum member 'jncolin' (jncolin)]
http://forums.java.net/jive/thread.jspa?messageID=208743