I'm migrating from Oracle JDK8 to OpenJDK11. I am facing problem with exportObject(new Myobj) call.
As rmi is removed in jdk11, I am using glassfish jars for PortableRemoteObject usage to export and lookup remote objects
I am using below jars from glassfish to get missing classes in openjdk11.
- glassfish-corba-omgapi
 - glassfish-corba-orb
 - javax.transaction.api
 - pfl-dynamic
 - pfl-basic
 - glassfish-corba-internal-api
 - pfl-tf.jar
 
I am expecting javax.rmi.PortableRemoteObject.PortableRemoteObject.exportObject() to work as is in JDK8. But I am getting below error. I tried to use com.sun.corba.ee.impl.javax.rmi.PortableRemoteObjet and also com.sun.corba.se.impl.javax.rmi.PortableRemoteObject from glassfish jars. But still facing same error.
java.rmi.NoSuchObjectException: object not exported at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.toStub(MyClass.java:18) at javax.rmi.PortableRemoteObject.toStub(PortableRemoteObject.java:132)
Ant task for RMIC
<!-- Ant task for RMIC -->  
   <target name="rmic">
    <taskdef name="rmic"
             classname="org.apache.tools.ant.taskdefs.Rmic" />
    <rmic classname="com.MyRmiImpl"
          base="${classes.dir}"
          classpathref="javac.classpath" />
  </target>
public class MyNode {
static Registry registry;
public static void main(String[] args) {
        try {
        registry = LocateRegistry.createRegistry(3322);
        MyRmiImpl remoteImpl = new MyRmiImpl();
        PortableRemoteObject.exportObject(remoteImpl); 
        Remote objStub = PortableRemoteObject.toStub(remoteImpl);// getting exception at this line 
        registry.rebind("MyRmiInterface", objStub);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
}