users@glassfish.java.net

EJB look up problem between 2 ear's - Glassfish v3

From: <glassfish_at_javadesktop.org>
Date: Mon, 20 Sep 2010 10:44:13 PDT

Hi,

I have recently started migrating from JBoss AS 5.x to Glassfish v3.

I was able to migrate most of the components easily than the below scenario:

1. I have 2 EAR's (EAR1 & EAR2)
2. Both these EARs have EJB modules, web modules
 namely EAR1 ----> EJB1, WAR1, a jar file containing the EJB1 interfaces (local + remote)
             EAR2 ----> EJB2, WAR2, a jar file containing the EJB2 interfaces (local + remote)

My need is that in one of the stateless session bean (SLSB2) present in EJB2 module, I want to get handle on a SLSB1 present in EJB1 (present in EAR1).

SLSB1 has a local interface (annotated with @Local).

I have tried these options:
1. In SLSB2, used
@EJB (mappedName="xxxxxx")
public SLSB1ManagerLocal slsb1manager;

where "xxxxxx" is the global jndi name of SLSB1. This didn't work

2. Used the sun-ejb-jar.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD
Application Server 9.0 EJB 3.0//EN'
'http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd'>
<ejb-jar>
<display-name>SLSB2 module</display-name>
<enterprise-beans>
        <ejb>
                <ejb-name>SLSB1ManagerLocal</ejb-name>
                <jndi-name>java:global/EAR1/EJB1-ejb-2.0-SNAPSHOT/SLSB1Manager</jndi-name>
                
                <!-- Tried this jndi-name as well, but no luck -->
                <!-- <jndi-name>java:global/EAR1/EJB1-ejb-2.0-SNAPSHOT/SLSB1Manager!com.xxx.yyy.ss.ejbone.api.SLSB1ManagerLocal</jndi-name> -->
                
        </ejb>
</enterprise-beans>
</ejb-jar>

And this is how I access this in my SLSB2:

        @EJB(name="SLSB1ManagerLocal")
        public SLSB1ManagerLocal slsb1manager;

But I get the below exception during deployment:
java.lang.RuntimeException: Cannot resolve reference Local ejb-ref name=SLSB1ManagerLocal,
Local 3.x interface =com.xxx.yyy.ss.ejbone.api.SLSB1ManagerLocal,ejb-link=null,lookup=null,mappedName=,jndi-name=,refType=Session
at com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:587)
        at com.sun.enterprise.deployment.EjbDescriptor.visit(EjbDescriptor.java:2411)
        at com.sun.enterprise.deployment.EjbBundleDescriptor.visit(EjbBundleDescriptor.java:726)
        at com.sun.enterprise.deployment.Application.visit(Application.java:1744)
        at com.sun.enterprise.deployment.archivist.ApplicationArchivist.validate(ApplicationArchivist.java:774)
        at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openWith(ApplicationArchivist.java:253)
        at com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:222)
        at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:145)
        at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:78)

Everything works fine if I bundle the EJB1 with EAR2 along with EJB2.

But this is not what I want. I want to invoke EJB1 from EJB2.

Can anyone please help me with this? I tried to google on this, but couldn't find any luck with the solutions that I found.

Thanks!
[Message sent by forum member 'kirank174']

http://forums.java.net/jive/thread.jspa?messageID=483171