Remote EJB Lookup Between two ears in glassfish 2.1

I have 2 EARS. The first EAR contains all the jars with the interfaces (EAR_INTERFACE.ear). These interfaces are marked as remote.

The second ear contains the ejbs(EAR_EJB). These ejbs implement the @remote interfaces from the first ear.The EJBs are stateless and have mappedName. In order to get the reference to the ejb i do a jndi lookup using the mappedName of the ejb in my second EAR.

Here i face the issue, i am not able to get the reference to the Remote EJBs. If the interface and ejbs are in the same EAR, then lookup is successful, but it fails between different EARs.

I am using glassfish server v2.1, ejb 3.0.

I searched for this issue and found out about parent child EARs. Will this solve my issue. If yes how to implement this. Do i need to mention something in application.xml of the EAR.

Please suggest me the best option to solve the issue.


It looks like there is issue with glassfish 2.1

If the interface is not in the same module as the ejb is the lookup fails. The interface is not loaded by the classloader and so stub is not generated.

My ejb jar was in a ear and the interface was in another jar. Some how i found out workaround for this issue. Before deployement of the ear, keep the interface jar in the domain/domain1/lib/ext, restart the glassfish. Deploy the ear containing the ejbs. After deployment is done successfully, copy the interface jar to the application/j2ee-apps/ and re-start the glassfish. Then if i try to do lookup, the lookup succeds.

If someone faced out similar issue or has some better workaround, plase reply.

Thanks


How do you do the JNDI Lookup?

We have some GF 2.1 Server and if the EJB's are in different projects, the only solution was to look it up like this:

RemoteInterface bean = null;
Properties props = new Properties();
props.setProperty("org.omg.CORBA.ORBInitialHost", "host");
props.setProperty("org.omg.CORBA.ORBInitialPort", "port");
InitialContext ctx = new InitialContext(props);
RemoteInterface bean = (RemoteInterface)
ctx.lookup("full.qualified.name.RemoteInterface");
链接地址: http://www.djcxy.com/p/58782.html

上一篇: 如何使用@EJB与远程接口“

下一篇: 远程EJB查找在glassfish中的两个耳朵之间2.1