Java 11 and jacorb. ClassNotFoundException: javax.rmi.CORBA.Stub

喜你入骨 提交于 2021-01-18 06:59:29

问题


I am trying to execute my application of java 11 (openjdk) with jacorb 3.9.The application starts executing but crashes complaining about missing :

javax.rmi.CORBA.Stub

I have included all jacorb libraries in the CLASSPATH

set CLASSPATH = ${JACORB_PATH}/jacorb.jar:${CLASSPATH}
set CLASSPATH = ${JACORB_PATH}/jacorb-3.9.jar:${CLASSPATH}
set CLASSPATH = ${JACORB_PATH}/jacorb-omgapi.jar:${CLASSPATH}
set CLASSPATH = ${JACORB_PATH}/slf4j-api.jar:${CLASSPATH}
set CLASSPATH = ${JACORB_PATH}/slf4j-jdk14-1.7.14.jar:${CLASSPATH}
set CLASSPATH = ${JACORB_PATH}/jacorb-services.jar:${CLASSPATH}
set CLASSPATH = ${JACORB_PATH}/picocontainer.jar:${CLASSPATH}
set CLASSPATH = ${JACORB_PATH}/wrapper.jar:${CLASSPATH}
set CLASSPATH = ${JACORB_PATH}/antlr.jar:${CLASSPATH}
set CLASSPATH = ${JACORB_PATH}/idl.jar:${CLASSPATH}

When executing , I get this:

java.lang.reflect.InvocationTargetException
...
Caused by: java.lang.ClassNotFoundException: javax.rmi.CORBA.Stub
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)

I have tried also to set up the JDK_JAVA_OPTIONS with:

--module-path ${JACORB_PATH} --add-modules java.corba 
-Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB -Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton

But complains about "Two versions of module slf4j.jdk14 found"

The command for executing the program is:

java -classpath $CLASSPATH myprog.MYPROG 

The application was originally written for Java 8 and working OK with jacorb passing the following parameters to java command:

-Djava.endorsed.dirs=JACORB_PATH
-Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB
-Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton

The application does not use rmi at all. It is a 'classic' CORBA client. It crashes when trying to resolve the initial reference of the naming Service


回答1:


It seems that the issue have been raised on the project mailing list. A workaround is to add on the classpath next to jacorb-3.8.jar and the sfl4j jars these 2:

  • jacorb-omgapi-3.8.jar - from JacORB distribution
  • jboss-rmi-api_1.0_spec-1.0.6.Final.jar - from https://github.com/jboss/jboss-rmi-api_spec. This library provides the Java RMI API which was originally used by JacORB from the JRE. (Maven)



回答2:


Following JEYs suggestion to substitue the class javax.rmi.CORBA.Stub missing in JDKS 9 and later, I composed a stub component from a dozen of relevant JDK-8-classes and this worked. The code coverage of the javax.rmi.CORBA.Stub turned out to reduce to the Stub.toString() method, which again by context just calls the super class method.

So the solution for JDK 9, 10 (and probably later) is to have an empty Java class surrogate, satisfying the class loader; JacOrb sources could use class ObjectImpl instead, to finally pintch off transient RMI stuff.

package javax.rmi.CORBA;

import org.omg.CORBA_2_3.portable.ObjectImpl;

/**
 * JacOrb 3.9 surrogate 
 * [Base class from which all RMI-IIOP stubs must inherit.]
 */
public abstract class Stub extends ObjectImpl implements java.io.Serializable
{
}

Endorsement of JacOrb libraries and class name replacement is obsolete after JDK 8.



来源:https://stackoverflow.com/questions/56327632/java-11-and-jacorb-classnotfoundexception-javax-rmi-corba-stub

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!