I reduced this problem to a very simple "Hello World" sample:
1) A library jar with one Remote interface (InterfaceEJB.jar):
public interface SimpleEJBRemote {
String hello();
}
2) An Enterprise Application (ear) deployed on SERVER1 with an EJB
Module (EJBModule.ear containing /lib/InterfaceEJB.jar and
EJBModule.jar) and a SLSB:
@Stateless
@Remote(value=SimpleEJBRemote.class)
public class SimpleEJBBean implements SimpleEJBRemote {
@Override
public String hello() {
return "Hello world...";
}
}
3) A Web Application (WebRemote.war) deployed on SERVER2 containing
WEB-INF/lib/InterfaceEJB.jar and a servlet, calling the remote EJB:
public class SimpleServlet extends HttpServlet {
private SimpleEJBRemote _remoteService;
public SimpleServlet() {
try {
final Properties env = new Properties();
env.setProperty("org.omg.CORBA.ORBInitialHost", 127.0.0.1");
env.setProperty("org.omg.CORBA.ORBInitialPort", "3100");
InitialContext context = new InitialContext(env);
// all fail ..
_remoteService = (SimpleEJBRemote) context.lookup(
SimpleEJBRemote.class.getCanonicalName());
//"SimpleEJBRemote");
//"java:global/SimpleEJBBean");
//"java:global/EJBModule/EJBModule-ejb/SimpleEJBBean");
} catch (Exception ex) {
ex.printStackTrace();
}
}
... standard code
}
I get the following exception:
javax.naming.NamingException: Lookup failed for 'sample.SimpleEJBRemote'
in SerialContext
targetHost=127.0.0.1,targetPort=3100,orb'sInitialHost=127.0.1.1,orb'sInitialPort=4037
[Root exception is javax.naming.NamingException: Unable to acquire
SerialContextProvider for SerialContext
targetHost=127.0.0.1,targetPort=3100,orb'sInitialHost=127.0.1.1,orb'sInitialPort=4037
[Root exception is java.lang.ClassCastException]]
at
com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442)
...
Caused by: java.lang.ClassCastException: Object is not of remote type
com.sun.enterprise.naming.impl.SerialContextProvider
at
com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:250)
If i change the lookup code to:
InitialContext context = new InitialContext();
_remoteService = (SimpleEJBRemote)
context.lookup("corbaname:iiop:127.0.0.1:3100#sample.SimpleEJBRemote");
I get the following exception:
javax.naming.NameNotFoundException [Root exception is
org.omg.CosNaming.NamingContextPackage.NotFound:
IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
at
com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:44)
...
Caused by: org.omg.CosNaming.NamingContextPackage.NotFound:
IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
at
org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:72)
If I use GF 2.1.1 for both SERVER1 and SERVER2, everthing goes well
If I use GF 3.0.1 for both SERVER1 and SERVER2, everthing goes well
The exceptions occurs when SERVER1 is GF 2 and SERVER2 is GF 3
Who knows what I am doing wrong??
Regards,
Ronald