An ejb local home needs to be accessed using an ejb-local-ref. For example, this ejb-jar.xml fragment shows the CallerBean referencing the CalleeBean:
<session> <description>A secured echo session bean that calls a StatelessSessionLocal when its invokeEcho method is called. </description> <ejb-name>CallerBean</ejb-name> <home>org.jboss.test.security.interfaces.CallerSessionHome</home> <remote>org.jboss.test.security.interfaces.CallerSession</remote> <ejb-class>org.jboss.test.security.ejb.CallerBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> <ejb-local-ref> <ejb-ref-name>ejb/local/CalleeHome</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>org.jboss.test.security.interfaces.StatelessSessionLocalHome</local-home> <local>org.jboss.test.security.interfaces.StatelessSessionLocal</local> <ejb-link>CalleeBean</ejb-link> </ejb-local-ref> </session> ... <session> <description>A secured echo session bean that is called by CallerBean </description> <ejb-name>CalleeBean</ejb-name> <local-home>org.jboss.test.security.interfaces.StatelessSessionLocalHome</local-home> <local>org.jboss.test.security.interfaces.StatelessSessionLocal</local> <ejb-class>org.jboss.test.security.ejb.CalleeBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session>
The ejb-local-ref/ejb-ref-name name of "ejb/local/CalleeHome" means that the CalleeBean local home will be bound under the java component environment naming context (java:comp/env) with that relative name:
InitialContext ctx = new InitialContext(); StatelessSessionLocalHome home = (StatelessSessionLocalHome) ctx.lookup("java:comp/env/ejb/local/CalleeHome"); ...
Why is there a "@xxxxxx" in my local ejb JNDI name?
See WhyDoesTheLocalNameContainARandomNumber
Referenced by:
Comments