这是我的服务器类:
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import org.omg.CORBA.ORB;
import org.omg.CORBA.ORBPackage.InvalidName;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAHelper;
import org.omg.PortableServer.POAManagerPackage.AdapterInactive;
import org.omg.PortableServer.POAPackage.ObjectNotActive;
import org.omg.PortableServer.POAPackage.ServantAlreadyActive;
import org.omg.PortableServer.POAPackage.WrongPolicy;
public class BehaviorServer {
/**
* @param args
* @throws InvalidName
* @throws WrongPolicy
* @throws ServantAlreadyActive
* @throws ObjectNotActive
* @throws FileNotFoundException
* @throws AdapterInactive
*/
public static void main(String[] args) throws InvalidName, ServantAlreadyActive, WrongPolicy, ObjectNotActive, FileNotFoundException, AdapterInactive {
ORB orb=ORB.init(args,null);
POA rootPOA=POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
BehaviorImpl aBehavior=new BehaviorImpl();
byte[] id=rootPOA.activate_object(aBehavior);
org.omg.CORBA.Object ref=rootPOA.id_to_reference(id);
String ior=orb.object_to_string(ref);
System.out.println(ior);
PrintWriter file=new PrintWriter("ior.txt");
file.println(ior);
rootPOA.the_POAManager().activate();
orb.run();
}
}
我的客户:
public class BehaviorClient {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
ORB orb=ORB.init(args,null);
BufferedReader br=new BufferedReader(new FileReader("ior.txt"));
String ior=br.readLine();
br.close();
org.omg.CORBA.Object o=orb.string_to_object(ior);
Behavior aBehavior=BehaviorHelper.narrow(o);
aBehavior.eat();
}
}
我得到的错误:
Nov 02, 2014 11:58:00 PM com.sun.corba.se.impl.orb.ORBImpl string_to_object
WARNING: "IOP00110201: (BAD_PARAM) Null parameter"
org.omg.CORBA.BAD_PARAM: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.se.impl.logging.ORBUtilSystemException.nullParam(Unknown Source)
at com.sun.corba.se.impl.logging.ORBUtilSystemException.nullParam(Unknown Source)
at com.sun.corba.se.impl.orb.ORBImpl.string_to_object(Unknown Source)
at animal.BehaviorClient.main(BehaviorClient.java:22)
我已经查看了有关此问题的其他问题,但这对我没有帮助。查找了这些: Java CORBA 中的 Bad_Param 尝试初始化我的 ORB Orb 初始化