在java中成功地初始化了Corba通知服务,但在linux下无法得到任何事件,但在windows下已经完成了
【腾讯云】亏本大甩卖,服务器4核16G 1年370元(带宽12M,系统盘120GB SSD盘,月流量2000GB)!!!!!!
云产品 配置 价格
服务器 1核2G,带宽5M,系统盘50GB SSD盘,月流量500GB 38元/年
MySQL 1核1G 19元/年
服务器 16核32G,带宽18M,系统盘250GB SSD盘,月流量5000GB 1197元/年
点我进入腾讯云,查看更多详情

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: + 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();
  • The method 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;
    
    }
    
  • 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);
    }
    

    }

  • The disconnect() method:

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

#0

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

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

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

#1

I think your object activation is missing. It may be that the ORB behaviour is not fully defined at this poitn, so you'd use more explicit activation here.

// 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);
}

推荐文章

如何编写并行.ForEach有一个固定参数和另一个来自集合的参数?

如何编写并行.ForEach有一个固定参数和另一个来自集合的参数?

推荐文章

使用tkinter Scale widget数据进行列表理解

使用tkinter Scale widget数据进行列表理解

推荐文章

正确配置主干线木偶中的父子关系路由器

正确配置主干线木偶中的父子关系路由器

推荐文章

计算概率并在Excel中绘制cdf

计算概率并在Excel中绘制cdf

推荐文章

在用户单击“更新文本”时查看

在用户单击“更新文本”时查看

推荐文章

为什么MessageDigest为同一个字符串返回不同的答案?

为什么MessageDigest为同一个字符串返回不同的答案?

推荐文章

在Android中创建聊天泡泡

在Android中创建聊天泡泡

推荐文章

Aptana3代码辅助googlemapsapiv3

Aptana3代码辅助googlemapsapiv3

推荐文章

MySQL无法使用FK约束插入

MySQL无法使用FK约束插入

推荐文章

如何在不获取“IOError:closed stream”的情况下在rails应用程序中创建一个quefrom守护进程

如何在不获取“IOError:closed stream”的情况下在rails应用程序中创建一个quefrom守护进程

推荐文章

如何使用备用发件人/组织者创建Outlook会议请求?

如何使用备用发件人/组织者创建Outlook会议请求?

推荐文章

正在获取相关对象

正在获取相关对象

推荐文章

在XSD中引用名称空间

在XSD中引用名称空间

推荐文章

Facebook Android教程中的“Android库项目无法启动”

Facebook Android教程中的“Android库项目无法启动”

推荐文章

JSCH和多线程java应用程序的问题

JSCH和多线程java应用程序的问题

推荐文章

iPhone、iPad和其他移动设备上的Silverlight

iPhone、iPad和其他移动设备上的Silverlight