本文介绍了在java中成功初始化Corba通知服务,但无法在linux中获取任何事件,但它在Windows中完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我测试用Java编写的应用程序时,我对一个奇怪的错误感到头疼。问题在于:我编写的应用程序使用了CORBA连接技术。它是一个CORBA客户端应用程序模块。在Windows环境中,事件被成功推送,但在linux(redhat和ubuntu)中却没有。但是,它非常怪异,我可以调用任何CORBA函数并准确地获取返回的数据。我调试了我的代码,看到CORBA连接和通知服务的初始化成功了。在Linux OS中,防火墙被禁用,端口12002未被任何应用程序使用。这里没有任何例外。那么,你能解释一下原因是什么吗?我对CORBA的经验不足。像我这样的新手这么复杂。请帮助我!

I got a headache about a freaky error when i'm testing my application written in Java. The problem is here: I've written my application used CORBA connection technology. It's an CORBA client application module. In windows environment, the events was pushed successfully but in linux (both redhat and ubuntu) it wasn't. However, it's so freaky that i can call any CORBA functions and get the returned data exactly. I debugged my code, and saw that the initialization of CORBA connection and notification service was successful. In Linux OS, the firewall was disabled and the port 12002 was unused by any applications. It has no any exceptions here. So, could you explain for me what the reason can be here. I have less experience about CORBA. It's so complicated for newbie like me. Help me, please!

P / s:
+初始化代码如下:

P/s: + The initialize code is below:

        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():

    • The method getObject():

      private StructuredPushConsumer getObject(){
      StructuredPushConsumer serverObj = null;

      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()方法:

    • The connect() method:

       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()方法:

      The disconnect() method:

      public void disconnect() {    
          if (proxy != null) {
              System.out.println("Disconnected!");
          }
      }
      


    • 推荐答案

      也许这不是SW相关的问题,而是硬件/网络。

      Maybe it's not SW related problem but HW/Networking.

      如果你使用多主机(多个网卡/接口) ),那么你应该指定接收CORBA通知的IP地址。

      If you use multihost computer (more than one network card/interface), then you should specify IP address for receiving CORBA notification.

      查看您的属性文件。
      我使用的是JacOrb,因此文件是 etc \\ .jacorb.properties ,属性跟随
      OAAddress = iiop://1.2.3.4:4711

      Take a look into your properties file. I used JacOrb, so file is etc\jacorb.properties and property is followingOAAddress=iiop://1.2.3.4:4711

      这篇关于在java中成功初始化Corba通知服务,但无法在linux中获取任何事件,但它在Windows中完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 23:20