我正在从Oracle JDK8迁移到OpenJDK11。我遇到了exportObject(new Myobj)调用的问题。
由于在jdk11中删除了rmi,因此我正在使用Glassfish罐子来使用PortableRemoteObject来导出和查找远程对象
我正在用玻璃鱼罐子下面的东西来打开openjdk11中缺少的类。
我期望javax.rmi.PortableRemoteObject.PortableRemoteObject.exportObject()能够像在JDK8中一样工作。但是我越来越错误了。我尝试从玻璃鱼缸中使用com.sun.corba.ee.impl.javax.rmi.PortableRemoteObjet以及com.sun.corba.se.impl.javax.rmi.PortableRemoteObject。但是仍然面临着同样的错误。
java.rmi.NoSuchObjectException:对象不在com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.toStub(MyClass.java:18)处导出,位于javax.rmi.PortableRemoteObject.toStub(PortableRemoteObject.java: 132)
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>
公共类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();
}
}
}