3

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

}

user207421
  • 305,947
  • 44
  • 307
  • 483
Techie
  • 39
  • 1
  • 3
  • [RMI is **not** removed from JDK 11](https://www.oracle.com/pls/topic/lookup?ctx=en/java/javase/11/core&id=RMIUG-GUID-70825E99-57CF-470F-871A-5CCB6C2771BE). – user207421 Jun 19 '19 at 02:38
  • How did you resolve this? – donlys Jul 23 '19 at 18:32
  • @donlys Resolve what? There is no problem to resolve. The link I provided proves it. – user207421 Aug 02 '19 at 00:53
  • And here is the [OpenJDK 11 RMI Javadoc link](http://cr.openjdk.java.net/~iris/se/11/spec/pfd/java-se-11-pfd-spec/api/java.rmi/module-summary.html). It is also [present in OpenJDK 12](https://cr.openjdk.java.net/~iris/se/12/latestSpec/api/java.rmi/module-summary.html). I don't know what you people are talking about. @donlys – user207421 Aug 04 '19 at 07:36
  • 2
    My question is how do I rewrite existing code that is using PortableRemoteObject.narrow – donlys Aug 05 '19 at 18:10
  • 1
    @Donlys Rerwite it why? NB This question is based on a complete misunderstanding of the error message. `NoSuchObjectException` refers to a stub expiry, not to a complete removal of an API from the JDK, and it relies on code that is basically meaningless in the first place, being a mixture of RMI/JRMP and RMI/IIOP. You should ask your question, whatever it is, in a new thread. – user207421 Aug 06 '19 at 11:14

0 Answers0