2 Replies Latest reply on Apr 14, 2005 1:56 PM by sunfire

    corba tcp connection remains after destoying the orb and und

    sunfire

      Hi all,
      I have written a ejb3 service that connects to a remote corba server and other EJBs use it to communnicate via XML with the remote server(this part is working nicely). I don't know if this is the way a ORB/CORBA setup is supposed to be done. So if you have any suggestions please let me know how to do it right. Don't want to paste the whole code but only the parts that I think do matter:

      First I create the ORB/CORBA stuff in the EJBs create() method

      System.out.println("Setting Properties");
      _props = new java.util.Properties();
      
      _props.put ("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
      _props.put ("org.omg.CORBA.ORBInitialHost", "some.host.com");
      _props.put ("org.omg.CORBA.ORBInitialPort", "123456");
      _props.put ("org.omg.CORBA.ORBClass",
       "com.sun.corba.se.internal.iiop.ORB");
      _props.put ("org.omg.CORBA.ORBSingletonClass",
       "com.sun.corba.se.internal.iiop.ORB");
      
      System.out.println("init orb");
      _orb = org.omg.CORBA.ORB.init((String[])null, _props);
      _nameService = _orb.resolve_initial_references ("NameService");
      _ncRef = NamingContextHelper.narrow(_nameService);
      NameComponent nc = new NameComponent ("OSSServer", "");
      NameComponent path[] = {nc};
      _server = ServerHelper.narrow(_ncRef.resolve (path));
      ...etc...
      

      And this in the EJBs destroy() method
      _server = null;
      _ncRef = null;
      _nameService = null;
      _orb.shutdown(true);
      _orb.destroy();
      _orb = null;
      

      After I deployed the EJB everything works fine and I can communicate with the corba server as I want to. I see 2 tcp network connections to the other corba server:
      tcp 0 0 12.34.45.67:37099 some.host.com:123456 ESTABLISHED
      tcp 0 0 12.34.45.67:37097 some.host.com:123456 ESTABLISHED
      

      The thing that I don't understand is that when I undeploy the EJB and the destroy() method is called I still see the two network connections even when the EJB and its ORB and everything is long gone...
      And when I redeploy the EJB I see 4 tcp connections. Might be a very stupid thing but I am very new to the whole jee/corba thing. So can sombedy point me into the right direction or to some documentation about how to do it right?

      Many thanks!

        • 1. Re: corba tcp connection remains after destoying the orb and

          Perhaps the connections are remaining open until _ncRef and _server are garbage collected. You can try changing your destroy() method to:

          if (_server != null) {
           _server._release();
           _server = null;
          }
          if (_ncRef != null) {
           _ncRef._release();
           _ncRef = null;
           _nameService = null;
          }
          _orb.shutdown(true);
          _orb.destroy();
          _orb = null;
          

          I think destroying the ORB only releases connections from object adaptors that you've registered with the ORB. I don't think it closes any connections obtained from references to remote services. I could be wrong.



          • 2. Re: corba tcp connection remains after destoying the orb
            sunfire

             

            "anguyen" wrote:
            Perhaps the connections are remaining open until _ncRef and _server are garbage collected.

            I tried it now but it does not work. :( The connections are still there even after a call to the _release() methods and to System.gc().