I'm trying to use Java 9 as client application runtime, to call EJB (EJB 2.0) deployed on JBoss v7 EAP running with Java 8. Following parameter can work with Java 6/7/8.:
-Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory
to enable CORBA for Java 9, parameter:
--add-modules ALL-SYSTEM
is added to command line, first line returns an CORBA object, but second line javax.rmi.PortableRemoteObject.narrow(...)
returns an null
:
Object ref = mContext.lookup("MyEar/MyEJBModuleName/MyEJBHome"); //OK
MyEJBHome home = (MyEJBHome)
javax.rmi.PortableRemoteObject.narrow(ref, MyEJBHome.class); //KO.
this code fragment can work with Java 6/7/8, but fails with Java 9. I have added ALL-SYSTEM
modules, are there any other dependencies or parameters missing?
Edit@2017.11.16:
I got answer to it:
with JDK 8, its IIOP implements try to create dynamic stub, so I don't need provide stub classes, but JDK 9, it try to load 2 stub classes with names: com.ts.uiserver._UIServerHome_Stub & org.omg.stub.com.ts.uiserver._UIServerHome_Stub, my jar doesn't contains them, now I created following 4 stub classes with rmic command:
com.ts.uiserver._UIServerHome_Stub
com.ts.uiserver._UIServer_Stub
org.omg.stub.javax.ejb._EJBHome_Stub
org.omg.stub.javax.ejb._EJBObject_Stub
, with 4 stubs, my program works now.
now I get another question:
- what's pros and cons of static stub vs. dynamic stub?
- when static stubs not found why its implementations don't try to generate dynamic stub?
I also explicitly added '-Dcom.sun.CORBA.ORBUseDynamicStub=true' to command line, it seems that this parameter is not used actually, after search source code 'src.zip' of Java 9, this parameter is still mentioned.