2

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!");
        }
    }
    
LU RD
  • 34,438
  • 5
  • 88
  • 296
Dzung Nguyen
  • 113
  • 2
  • 8
  • could you please provide more details about your application deployment? What exactly is your problem? the network connectivity? – tuergeist Mar 03 '12 at 21:32
  • When i was developing my Java desktop application in windows, it could get any structured events from Corba server. But when i run my code and debugged in linux (using eclipse), it didn't get any pushed events from Corba server module. The notification service was listening at port 12002, and the firewall was disabled. – Dzung Nguyen Mar 04 '12 at 05:00
  • And you do not get any errors? – tuergeist Mar 04 '12 at 17:57
  • Yes, exactly. That's so freaky. :( – Dzung Nguyen Mar 05 '12 at 01:30
  • Both, server and client are running on the same host? – tuergeist Mar 05 '12 at 10:24
  • Are you able to telnet the notification service at x.x.x.x:12002 from the client? (even if its on the same host?) – tuergeist Mar 05 '12 at 10:24
  • Of course, i can telnet to the notification service from the client; and in two cases: both server and client are on the same host and separately. – Dzung Nguyen Mar 05 '12 at 12:01
  • If you use visibroker beware of the license stuff. no license, no fun. Btw I'm a little confused about `thread.setName("OpenFusion ORB thread");` as PrismTech provides OpenFusion ORB as a brand, e.g., for a fancier JacORB... – tuergeist Mar 05 '12 at 14:08
  • It's just a thread name. I copied some example code in the Internet to make it run. But it doesn't run well on linux. As i searched on Internet, the reason may be the supplier was hanged, so that the consumer doesn't call method push_structured_event_consumer(). Is it true? – Dzung Nguyen Mar 05 '12 at 15:19
  • Hmm. you shall provide the full code (server/client) via pastebin.com or so. I cannot find any error in the given code, but it is not complete – tuergeist Mar 05 '12 at 15:41
  • Hi, tuergeist. I've finished uploading my PushConsumer code at URL: http://pastebin.com/AyY5GQLn. Could you check it for me? – Dzung Nguyen Mar 06 '12 at 01:38
  • The notification service server used TAO Notify service. It's an application, i don't have its source code. The OS of host of TAO notify service is windows XP pro SP 2. – Dzung Nguyen Mar 06 '12 at 03:26

2 Answers2

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

PK69
  • 1
0

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);
}
tuergeist
  • 9,171
  • 3
  • 37
  • 58
  • I try with your method, it's not so different from my above getObject() method. And finally, it still doesn't push any events to event channel. I used WireShark to catch IP packet of notify server and notify client ethernet card. In windows host, i caught the event packet but in linux, there is no one. So the problem is still here. Do you have another solution? – Dzung Nguyen Mar 07 '12 at 01:49
  • btw. this is the push consumer! not the event producer! – tuergeist Mar 07 '12 at 09:10
  • Yes, exactly. I think the problem is the event supplier does not push any events to event channel, so that push consumer cannot catch any events. And my code is still right. – Dzung Nguyen Mar 08 '12 at 07:09