Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating from Oracle JDK8 to Open jdk11, looking for rmi replacement

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();
    }
}

}

like image 507
Techie Avatar asked Dec 07 '25 10:12

Techie


1 Answers

As has been pointed out in the comments, javax.rmi did not get removed from JDK 11 but CORBA and RMI-IIOP did get removed. The result is javax.rmi.PortableRemoteObject is no longer available from the JDK.

If you only needed the PortableRemoteObject.narrow method for checking type, you might be able to replace it with a cast as shown in this diff.

Otherwise look into Glassfish for your CORBA needs.

implementation group: 'org.glassfish.corba', name: 'glassfish-corba-orb', version: '4.2.0'
like image 197
peater Avatar answered Dec 09 '25 23:12

peater



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!