I have created a simple EJB 3.0 application, deployed in JBOSS 7.1.1 final.
Here is the code:
EJB 1:
Interface
package com.example.server.local.bean;
import javax.ejb.Local;
@Local
public interface UtilLocalBeanLocal {
public String addString();
}
Class implementing this interface:
package com.example.server.local.bean;
import javax.ejb.Local;
import javax.ejb.Stateless;
@Stateless
@Local(value=UtilLocalBeanLocal.class)
public class UtilLocalBean implements UtilLocalBeanLocal {
public UtilLocalBean() {
}
@Override
public String addString() {
return "Added from Local bean";
}
}
So, this EJB i am creating to be "locally" used by another EJB.
EJB 2:
Interface
package com.example.bean.session;
import javax.ejb.Remote;
@Remote
public interface FirstBeanRemote {
public String callMe();
}
Class implementing this interface.
package com.example.bean.session;
import javax.ejb.EJB;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import com.example.server.local.bean.UtilLocalBeanLocal;
@Stateless
@Remote(value=FirstBeanRemote.class)
public class FirstBean implements FirstBeanRemote {
@EJB
private UtilLocalBeanLocal utilLocalBeanLocal;
public FirstBean() {
}
@Override
public String callMe() {
return "Hi there!" + utilLocalBeanLocal.addString();
}
}
When i start the JBOSS, the JNDI bindings i get are like this:
00:34:15,928 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-5) JNDI bindings for session bean named FirstBean in deployment unit subdeployment "EJB30TestProj.jar" of deployment "EJB30TestProjEAR.ear" are as follows:
java:global/EJB30TestProjEAR/EJB30TestProj/FirstBean!com.example.bean.session.FirstBeanRemote
java:app/EJB30TestProj/FirstBean!com.example.bean.session.FirstBeanRemote
java:module/FirstBean!com.example.bean.session.FirstBeanRemote
java:jboss/exported/EJB30TestProjEAR/EJB30TestProj/FirstBean!com.example.bean.session.FirstBeanRemote
java:global/EJB30TestProjEAR/EJB30TestProj/FirstBean
java:app/EJB30TestProj/FirstBean
java:module/FirstBean
However in the remote client when I try to use any of these above JNDI binding values, it is not working, and what actually works (after lot of google) is:
ejb:EJB30TestProjEAR/EJB30TestProj//FirstBean!com.example.bean.session.FirstBeanRemote
It is difficult to understand how this JNDI bindings work. JBOSS outputs a different JNDI and in reality what works is different one.
Can anyone please demystify this? (how to decide which JNDI bindings will work in different scenarios and any further pointers)