Инициализация службы уведомлений Corba в Java успешно, но не может получить никаких событий в Linux, но это сделано в Windows
У меня болит голова из-за странной ошибки, когда я тестирую свое приложение, написанное на Java. Проблема здесь: я написал, что мое приложение использовало технологию соединения CORBA. Это модуль клиентского приложения CORBA. В среде Windows события были успешно переданы, но в Linux (и Redhat, и Ubuntu) это не так. Однако это настолько странно, что я могу вызывать любые функции CORBA и точно получать возвращаемые данные. Я отладил свой код и увидел, что инициализация службы подключения и уведомления CORBA прошла успешно. В ОС Linux брандмауэр был отключен, а порт 12002 не использовался никакими приложениями. Здесь нет никаких исключений. Итак, не могли бы вы объяснить мне, в чем причина может быть здесь. У меня меньше опыта по поводу CORBA. Это так сложно для новичка, как я. Помоги мне, пожалуйста!
P / s: + Код инициализации ниже:
Properties props = new Properties();
/*props.setProperty("borland.enterprise.licenseDefaultDir", "C:/Borland/VisiBroker/license");*/
props.setProperty("org.omg.CORBA.ORBClass", "com.inprise.vbroker.orb.ORB");
props.setProperty("org.omg.CORBA.ORBSingletonClass", "com.inprise.vbroker.orb.ORBSingleton");
props.setProperty("javax.rmi.CORBA.StubClass", "com.inprise.vbroker.rmi.CORBA.StubImpl");
props.setProperty("javax.rmi.CORBA.UtilClass", "com.inprise.vbroker.rmi.CORBA.UtilImpl");
props.setProperty("javax.rmi.CORBA.PortableRemoteObjectClass", "com.inprise.vbroker.rmi.CORBA.PortableRemoteObjectImpl");
props.setProperty("vbroker.agent.enableLocator", "false");
props.setProperty("vbroker.orb.initRef", "NotificationService=corbaloc::x.x.x.x:12002/NotificationService");
try {
System.out.println("orb = org.omg.CORBA.ORB.init(new String[0], props);");
orb = org.omg.CORBA.ORB.init(new String[0], props);
} catch (Exception e) {
System.out.println("Fail initial orb for Noti-Service.."+e);
System.exit(1);
}
try {
org.omg.CORBA.Object poa = orb.resolve_initial_references("RootPOA");
rootPoa = POAHelper.narrow(poa);
} catch (org.omg.CORBA.ORBPackage.InvalidName e) {
System.out.println("Can't get RootPOA"+ e);
System.exit(1);
}
try {
rootPoa.the_POAManager().activate();
System.out.println("rootPoa.the_POAManager().activate();");
} catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) {
System.out.println("Can't activate POAManager"+ex);
System.exit(1);
}
Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownHook(orb)));
Thread thread = new Thread() {
public void run() {
orb.run();
}
};
thread.setName("OpenFusion ORB thread");
thread.start();
Метод getObject ():
private StructuredPushConsumer getObject () {StructuredPushConsumer serverObj = null;
org.omg.PortableServer.Servant servant = new StructuredPushConsumerPOATie(this, rootPoa); try { org.omg.CORBA.Object ref = rootPoa.servant_to_reference(servant); serverObj = StructuredPushConsumerHelper.narrow(ref); } catch (ServantNotActive e) { System.out.println("Unexpected Exception: "+e); System.exit(1); } catch (WrongPolicy e) { System.out.println("Unexpected Exception: "+e); System.exit(1); } return serverObj; }
Метод connect():
public void connect() { /* Defines the type of proxy required */ ClientType ctype = ClientType.STRUCTURED_EVENT; /* Holder to hold the proxy id */ org.omg.CORBA.IntHolder pid = new org.omg.CORBA.IntHolder(); /* Proxy supplier variable */ ProxySupplier proxySupplier = null; /* Obtain the consumer admin object reference */ ConsumerAdmin admin = channel.default_consumer_admin(); try { /* obtain a structured push supplier object reference. */ proxySupplier = ((ConsumerAdminOperations) admin).obtain_notification_push_supplier(ctype, pid); System.out.println("proxySupplier = ((ConsumerAdminOperations) admin).obtain_notification_push_supplier(ctype, pid);"); } catch (AdminLimitExceeded ex) { /* * Thrown if the admin object is unable to have any more proxy suppliers associated with it. */ System.err.println("Maximum number of proxies exceeded!"); System.exit(1); } /* Narrow the proxy supplier to a Structured Proxy Push Supplier */ proxy = StructuredProxyPushSupplierHelper.narrow(proxySupplier); try { /* connect the consumer to the proxy */ proxy.connect_structured_push_consumer(getObject()); System.out.println("proxy.connect_structured_push_consumer(getObject());"); } catch (AlreadyConnected e) { /* * This exception is thrown if a consumer is already connected to this proxy. This should not be thrown because the proxy has just been created. */ System.err.println("Already connected!"); System.exit(1); } catch (TypeError e) { /* * This exception is thrown if you attempt to connect a sequenced consumer to a structured proxy or vice versa. */ System.err.println("Type error!"); System.exit(1); }
}
Метод disconnect():
public void disconnect() { if (proxy != null) { System.out.println("Disconnected!"); } }
2 ответа
Я думаю, что активация вашего объекта отсутствует. Может случиться так, что поведение ORB не полностью определено в этой точке, поэтому вы бы использовали более явную активацию здесь.
// create TIE
StructuredPushConsumerPOATie pushConsumer =
new StructuredPushConsumerPOATie(this, rootPoa);
// activate object (may work without that)
rootPoa.activate_object(pushConsumer);
try {
// implicit activation
org.omg.CORBA.Object ref = pushConsumer._this_object();
serverObj = StructuredPushConsumerHelper.narrow(ref);
}
Может быть, это не проблема SW, а HW/Networking.
Если вы используете компьютер с несколькими хостами (более одной сетевой карты / интерфейса), вам следует указать IP-адрес для получения уведомления CORBA.
Посмотрите в свой файл свойств. Я использовал JacOrb, поэтому файл - это etc\jacorb.properties, а свойство соответствуетOAAddress=iiop://1.2.3.4:4711