JBoss 7.1.1 EJB Lookup using JNDI from one server to multiple server with different EJB modules
trupti.r Dec 19, 2013 4:07 AMHi,
Currently I have three JBoss AS 7.1.1 standalone instances. One of them is EJB client (Say Host 172.17.17.7) and other are publishing different EJB modules (Say Host 172.17.17.8 and 172.17.17.9).
Currently I am trying to do JNDI lookup as follow:
ejb-jar.xml
<ejb-jar id="ejb-jar_ID" version="2.1"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
<enterprise-beans>
<session>
<ejb-name>MyEjb</ejb-name>
<home>MyEjbRemoteHome</home>
<remote>MyEjbRemote</remote>
<ejb-class>MyEjbImpl</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</ejb>
jboss.xml
<jboss>
<enterprise-beans>
<session>
<ejb-name>MyEjb</ejb-name>
<jndi-name>java:/MyEjb</jndi-name>
</session>
<jboss>
JBOSS Server output excerpt after deploying EJB is
JNDI bindings for session bean named MyEjb in deployment unit subdeployment "myejjb-ejb.jar" of deployment "MyEjb.ear" are as follows:
java:global/MyEjb/myejb-ejb/MyEjb!com.test.MyEjbHome
java:module/MyEjb/myejb-ejb/MyEjb!com.test.MyEjbHome
java:jboss/MyEjb/myejb-ejb/MyEjb!com.test.MyEjbHome
I do look up of these EJB from code in JBoss AS server on 172.17.17.8 as follow:
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,JbossSettings.getInitialConextetFactory());
url = "remote://172.17.17.7:4447";
env.put(Context.PROVIDER_URL,url);
env.put(Context.SECURITY_PRINCIPAL,JbossSettings.getEusSecurityPrincipal());
env.put(Context.SECURITY_CREDENTIALS, JbossSettings.getEusSecurityCredentials());
InitialContext ctx = new InitialContext(env);
ctx.lookup("java:global/MyEjb/myejb-ejb/MyEjb!com.test.MyEjbHome");
But I am getting javax.naming.NameNotFoundException:
exception.
Even I tried to add the
<subsystem xmlns="urn:jboss:domain:naming:1.1">
<bindings>
<lookup name="UnLockServer" lookup="java:global/MyEjb/myejb-ejb/MyEjb!com.test.MyEjbHome"/>
</bindings>
</subsystem>
But of no help.
On the server hosting EJB I am getting logs as
JBAS011806: Channel end notification received, closing channel Channel ID 52e62c8e (inbound) of Remoting connection 53fe497b
Can some one help me what I am doing wrong?
Is there any tutorial or example available where I can invoke different EJB's on different JBoss AS 7 from different JBOSS AS 7