Skip to main content

Can't lookup a remote EJB2 from a EJB3

No replies
Joined: 2006-12-09


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:


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", "");
            props.setProperty("org.omg.CORBA.ORBInitialPort", "3791");
            ic = new InitialContext(props);
            String sJNDI="java:global/";
            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.