我正在尝试建立与华为 U2000 NBI corba 的连接以使用 .ior 文件进行连接以获取警报。我已经将 IDL 文件编译为 Java。下面是我初始化 ORB 的主要代码
package com.be.u2k;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import org.omg.CORBA.ORB;
import AlarmIRPSystem.AlarmIRP;
import AlarmIRPSystem.AlarmIRPHelper;
public class Main {
public static void main(String[] args) {
try {
String filename = System.getProperty ("user.home") + System.getProperty ("file.separator")+"u2k.ior";
File f = new File(filename);
if (!f.exists()) {
System.out.println("File " + filename + " does not exist.");
System.exit(-1);
} else if (f.isDirectory()) {
System.out.println("File " + filename + " is a directory.");
System.exit(-1);
}
BufferedReader br = new BufferedReader(new FileReader(f));
String iorContents = br.readLine();
br.close();
ORB orbWithIor = ORB.init(args, null);
org.omg.CORBA.Object obj = orbWithIor.string_to_object(iorContents);
AlarmIRP alarmIrp = AlarmIRPHelper.narrow(obj);
System.out.println("AlarmIRPHelper.narrow success!") ;
} catch (Exception e) {
System.out.println("ERROR : " + e) ;
e.printStackTrace(System.out);
}
}
}
为什么我在运行它时不断收到 BAD_PARAM 错误
java -jar ServerU2kAlarm.jar
admin@ip-10-44-0-10:~$ java -jar ServerU2kAlarm.jar
ERROR : org.omg.CORBA.BAD_PARAM: vmcid: 0x0 minor code: 0 completed: No
org.omg.CORBA.BAD_PARAM: vmcid: 0x0 minor code: 0 completed: No
at AlarmIRPSystem.AlarmIRPHelper.narrow(AlarmIRPHelper.java:60)
at com.be.u2k.Main.main(Main.java:36)
我的 ORB 对象是否遗漏了什么?谢谢。