glassfish
  1. glassfish
  2. GLASSFISH-6984

Local JNDI lookup fails if bound object is remote RMI object

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 9.1peur2
    • Fix Version/s: future release
    • Component/s: naming
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      6,984

      Description

      We have standalone RMI server which provides some services to our EJB
      application. On startup this server registers itself within application by
      making call to specialized bean. This bean registers reference to remote RMI
      object in JNDI tree. Prior to have RMI object registered, bean will check if
      JNDI Context path exists. If path does not exist it will be created and then
      RMI object will be rebound. In case of RMI server failure it will be restarted
      and new instance will be rebound each time with the same name in JNDI tree. So
      far it was working well with Weblogic and WebSphere. However, it fails with
      GlassFish if will try to lookup reference on second call at time when we are
      verifying JNDI path. For some reason, when JNDI lookup called inside container,
      GlassFish is trying to make a copy of registered object through its
      serialization. RMI stub extends org.omg.CORBA.portable.ObjectImpl which has
      transient property __delegate which will not be serialized. Result is
      exception with message “Caused by: org.omg.CORBA.BAD_OPERATION: The delegate
      has not been set!� here is full stack trace:
      Exception in thread "main" javax.naming.CommunicationException: serial context
      communication ex [Root exception is java.rmi.RemoteException: ; nested
      exception is:
      java.lang.RuntimeException: Cant copy Serializable object:]
      at com.sun.enterprise.naming.SerialContext.lookup
      (SerialContext.java:427)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at test.jndi.ejb.RMIClientEJB.getOrCreateContext(RMIClientEJB.java:153)
      at test.jndi.ejb.RMIClientEJB.registerRemote(RMIClientEJB.java:124)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke
      (NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke
      (DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at com.sun.enterprise.security.SecurityUtil$2.run(SecurityUtil.java:182)
      at java.security.AccessController.doPrivileged(Native Method)
      at
      com.sun.enterprise.security.application.EJBSecurityManager.doAsPrivileged
      (EJBSecurityManager.java:1041)
      at com.sun.enterprise.security.SecurityUtil.invoke
      (SecurityUtil.java:187)
      at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod
      (BaseContainer.java:2895)
      at com.sun.ejb.containers.BaseContainer.intercept
      (BaseContainer.java:3986)
      at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke
      (EJBObjectInvocationHandler.java:203)
      at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke
      (EJBObjectInvocationHandler.java:120)
      at $Proxy122.registerRemote(Unknown Source)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke
      (NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke
      (DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke
      (ReflectiveTie.java:154)
      at
      com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServan
      t(CorbaServerRequestDispatcherImpl.java:687)
      at
      com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch
      (CorbaServerRequestDispatcherImpl.java:227)
      at
      com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest
      (CorbaMessageMediatorImpl.java:1846)
      at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest
      (CorbaMessageMediatorImpl.java:1706)
      at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput
      (CorbaMessageMediatorImpl.java:1088)
      at
      com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback
      (RequestMessage_1_2.java:223)
      at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest
      (CorbaMessageMediatorImpl.java:806)
      at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch
      (CorbaMessageMediatorImpl.java:563)
      at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork
      (CorbaMessageMediatorImpl.java:2567)
      at
      com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run
      (ThreadPoolImpl.java:555)
      Caused by: java.rmi.RemoteException: ; nested exception is:
      java.lang.RuntimeException: Cant copy Serializable object:
      at com.sun.enterprise.naming.LocalSerialContextProviderImpl.lookup
      (LocalSerialContextProviderImpl.java:132)
      at com.sun.enterprise.naming.SerialContext.lookup
      (SerialContext.java:398)
      ... 31 more
      Caused by: java.lang.RuntimeException: Cant copy Serializable object:
      at com.sun.enterprise.naming.NamingUtils.makeCopyOfObject
      (NamingUtils.java:82)
      at com.sun.enterprise.naming.LocalSerialContextProviderImpl.lookup
      (LocalSerialContextProviderImpl.java:128)
      ... 32 more
      Caused by: org.omg.CORBA.BAD_OPERATION: The delegate has not been set! vmcid:
      0x0 minor code: 0 completed: No
      at org.omg.CORBA.portable.ObjectImpl._get_delegate(ObjectImpl.java:53)
      at com.sun.corba.ee.spi.presentation.rmi.StubAdapter.getDelegate
      (StubAdapter.java:174)
      at
      com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.selfAsBaseClass
      (BCELStubBase.java:214)
      at test.jndi.remote._TestRemote_DynamicStub.writeReplace
      (test/jndi/remote/_TestRemote_DynamicStub.java)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke
      (NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke
      (DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at java.io.ObjectStreamClass.invokeWriteReplace
      (ObjectStreamClass.java:977)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1030)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
      at java.util.Hashtable.writeObject(Hashtable.java:813)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke
      (NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke
      (DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at java.io.ObjectStreamClass.invokeWriteObject
      (ObjectStreamClass.java:890)
      at java.io.ObjectOutputStream.writeSerialData
      (ObjectOutputStream.java:1333)
      at java.io.ObjectOutputStream.writeOrdinaryObject
      (ObjectOutputStream.java:1284)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
      at java.io.ObjectOutputStream.defaultWriteFields
      (ObjectOutputStream.java:1369)
      at java.io.ObjectOutputStream.writeSerialData
      (ObjectOutputStream.java:1341)
      at java.io.ObjectOutputStream.writeOrdinaryObject
      (ObjectOutputStream.java:1284)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
      at java.util.Hashtable.writeObject(Hashtable.java:813)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke
      (NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke
      (DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at java.io.ObjectStreamClass.invokeWriteObject
      (ObjectStreamClass.java:890)
      at java.io.ObjectOutputStream.writeSerialData
      (ObjectOutputStream.java:1333)
      at java.io.ObjectOutputStream.writeOrdinaryObject
      (ObjectOutputStream.java:1284)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
      at java.io.ObjectOutputStream.defaultWriteFields
      (ObjectOutputStream.java:1369)
      at java.io.ObjectOutputStream.writeSerialData
      (ObjectOutputStream.java:1341)
      at java.io.ObjectOutputStream.writeOrdinaryObject
      (ObjectOutputStream.java:1284)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
      at java.util.Hashtable.writeObject(Hashtable.java:813)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke
      (NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke
      (DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at java.io.ObjectStreamClass.invokeWriteObject
      (ObjectStreamClass.java:890)
      at java.io.ObjectOutputStream.writeSerialData
      (ObjectOutputStream.java:1333)
      at java.io.ObjectOutputStream.writeOrdinaryObject
      (ObjectOutputStream.java:1284)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
      at java.io.ObjectOutputStream.defaultWriteFields
      (ObjectOutputStream.java:1369)
      at java.io.ObjectOutputStream.writeSerialData
      (ObjectOutputStream.java:1341)
      at java.io.ObjectOutputStream.writeOrdinaryObject
      (ObjectOutputStream.java:1284)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
      at com.sun.enterprise.naming.NamingUtils.makeCopyOfObject
      (NamingUtils.java:64)
      ... 33 more

      Here is a simple code which does that:
      public void registerRemote(TestRemote remote) throws Exception

      { Context ctx = getOrCreateContext ("test/JNDI_RMI/Remote"); ctx.rebind("RMI_Server", remote); }

      public Context getOrCreateContext(String path) throws Exception {

      if (path == null)

      { return null; }

      // this context will use LocalSerialContextProviderImpl for JNDI lookup
      and will fail on second call
      Context root = new InitialContext();
      Context parent = root;
      Context leaf = root;

      // Make sure path exists in JNDI tree and if it does not exist then
      create it
      // Find subcontxt which corresponds to path and return it
      StringTokenizer tokenizer = new StringTokenizer(path, "/");
      while (tokenizer.hasMoreTokens()) {
      String pathElement = tokenizer.nextToken();
      try

      { Object obj = parent.lookup(pathElement); leaf = (Context) obj; }

      catch (NameNotFoundException e) {
      try

      { leaf = parent.createSubcontext(pathElement); }

      catch (NamingException e1)

      { e1.printStackTrace(); break; }

      } catch (NamingException e)

      { e.printStackTrace(); throw e; }

      parent = leaf;
      }

      return leaf;
      }

      If in this method we replace this line:
      Context root = new InitialContext();

      With follow:

      Properties props = new Properties();
      // These two properties are making no difference
      // props.put
      (InitialContext.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitCo
      ntextFactory");
      // props.put(InitialContext.PROVIDER_URL, "iiop://localhost:3700");

      props.put("org.omg.CORBA.ORBInitialHost", "localhost");
      props.put("org.omg.CORBA.ORBInitialPort", "3700");

      // This context will use RemoteSerialContextProviderImpl and will not
      fail.
      Context root = new InitialContext(props);

      I have working example which has both implementations.

        Activity

        Hide
        vasylz added a comment -

        Changed title

        Show
        vasylz added a comment - Changed title
        Hide
        vasylz added a comment -

        Changed title

        Show
        vasylz added a comment - Changed title
        Hide
        vasylz added a comment -

        Created an attachment (id=2182)
        Test example

        Show
        vasylz added a comment - Created an attachment (id=2182) Test example
        Hide
        sanandal added a comment -

        "Reclassifying as P4 because this issue is not deemed "must fix" for this v2.1
        release whose primary release driver is SailFin.
        This issue will be scrubbed after this release and will be given the right
        priority for the next release."

        Show
        sanandal added a comment - "Reclassifying as P4 because this issue is not deemed "must fix" for this v2.1 release whose primary release driver is SailFin. This issue will be scrubbed after this release and will be given the right priority for the next release."
        Hide
        rmusser added a comment -
            • Issue 6984 has been confirmed by votes. ***
        Show
        rmusser added a comment - Issue 6984 has been confirmed by votes. ***
        Hide
        dochez added a comment -

        re assigning to mahesh for evaluation

        Show
        dochez added a comment - re assigning to mahesh for evaluation
        Hide
        Mahesh Kannan added a comment -

        Assigning to Cheng

        Show
        Mahesh Kannan added a comment - Assigning to Cheng
        Hide
        Tom Mueller added a comment -

        Bulk update to change fix version to "not determined" for all issues still open but with a fix version for a released version.

        Show
        Tom Mueller added a comment - Bulk update to change fix version to "not determined" for all issues still open but with a fix version for a released version.
        Hide
        Tom Mueller added a comment -

        Reassigning to component lead as the assignee is no longer with the project.

        Show
        Tom Mueller added a comment - Reassigning to component lead as the assignee is no longer with the project.

          People

          • Assignee:
            guojun.shan
            Reporter:
            vasylz
          • Votes:
            10 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: