Skip to main content

Can't lookup a remote EJB2 from a EJB3

No replies
rsoika
Offline
Joined: 2006-12-09

Hi,

I have a problem to lookup programmatically a remote EJB which is deployed on a GlassFish v2.
My Application is a JEE6 App running on GlassFish v3.
I can lookup the remote ejb without any problem when I use the glassfish-ejb.jar xml. I use an entry like:

 <ejb>
            <ejb-name>MyESI</ejb-name>
            <ejb-ref>
                <ejb-ref-name>ejb/MY_EJB_SERVICE_LOCAL</ejb-ref-name>
                <jndi-name>corbaname:iiop:ltest.net:3791#com.foo.BusinessServicesRemote</jndi-name>
            </ejb-ref>
        </ejb>

But I can not use the 'hard-coded' glassfish-ejb-jar.xml file because I need to lookup the same bean from different remote servers.
For that reason I use a code like this to lookup the ejb programmatically :

     props = new Properties();
        
            props.setProperty("org.omg.CORBA.ORBInitialHost", "ltest.net");
            props.setProperty("org.omg.CORBA.ORBInitialPort", "3791");
            ic = new InitialContext(props);
            String sJNDI="java:global/com.bmw.ucp.bus.facade.BusinessServicesRemote";
            service = (BusinessServicesRemote) ic.lookup(sJNDI);

But this did not work. I got a error:

java.lang.ClassCastException: Object is not of remote type com.sun.enterprise.naming.impl.SerialContextProvider

Has anyone an idea why this did not work? It seems to be something with the SerialInitContextFactory.

If anyone have an example how to lookup a ejb2 from a ejb3 remotely this would be helpful.

regards
Ralph