尝试运行根据this tutorial设置的corba服务器时,出现以下错误。如果我在已经安装了所有corba软件的另一台计算机上构建相同类型的服务器,则它可以正常工作,但是当我像这样将corba jar文件添加到类路径中时,它会收到此错误
org.omg.CORBA.INITIALIZE: Could not instantiate ORB implementation: org.jacorb.orb.ORB
如何避免此错误
完整的错误消息
java.lang.ClassNotFoundException: org.jacorb.orb.ORB
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)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at org.omg.CORBA.ORB.create(ORB.java:94)
at org.omg.CORBA.ORB.init(ORB.java:63)
at StartServer.main(StartServer.java:15)
ERROR: org.omg.CORBA.INITIALIZE: Could not instantiate ORB implementation: org.jacorb.orb.ORB
org.omg.CORBA.INITIALIZE: Could not instantiate ORB implementation: org.jacorb.orb.ORB
at org.omg.CORBA.ORB.create(ORB.java:99)
at org.omg.CORBA.ORB.init(ORB.java:63)
at StartServer.main(StartServer.java:15)
HelloServer Exiting ...
StartServer.java
import AdditionApp.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POA;
import java.util.Properties;
public class StartServer {
public static void main(String args[]) {
try{
// create and initialize the ORB //// get reference to rootpoa & activate the POAManager
ORB orb = ORB.init(args, null);
POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
// create servant and register it with the ORB
AdditionObj addobj = new AdditionObj();
addobj.setORB(orb);
// get object reference from the servant
org.omg.CORBA.Object ref = rootpoa.servant_to_reference(addobj);
Addition href = AdditionHelper.narrow(ref);
org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
NameComponent path[] = ncRef.to_name( "ABC" );
ncRef.rebind(path, href);
System.out.println("Addition Server ready and waiting ...");
// wait for invocations from clients
for (;;){
orb.run();
}
}
catch (Exception e) {
System.err.println("ERROR: " + e);
e.printStackTrace(System.out);
}
System.out.println("HelloServer Exiting ...");
}
}