Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4306285

RMI-IIOP error when deserializing object that has readResolve() method

XMLWordPrintable

    • fcs
    • x86
    • windows_nt
    • Not verified



      Name: sg39081 Date: 01/21/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-I)
      Java HotSpot(TM) Client VM (build 1.3-I, mixed mode)

      Consider the following RMI-IIOP program (file Test.java):

      class Quantity implements java.io.Serializable
      {
        public Object readResolve() throws java.io.ObjectStreamException
        { return this; }
      }

      interface Massive extends java.rmi.Remote
      {
        Quantity getMass() throws java.rmi.RemoteException;
      }

      public class Test extends javax.rmi.PortableRemoteObject implements Massive
      {
        public Test() throws java.rmi.RemoteException {}
        public Quantity getMass() throws java.rmi.RemoteException
        { return new Quantity(); }

        public static void main( String[] args )
        {
          System.setProperty( "java.naming.factory.initial",
                              "com.sun.jndi.cosnaming.CNCtxFactory" );
          try
          {
            javax.naming.Context naming = new javax.naming.InitialContext();
            naming.rebind( "Server", new Test() );
            ((Massive) javax.rmi.PortableRemoteObject.narrow(
              naming.lookup( "Server" ), Massive.class )).getMass();
          }
          catch ( Exception e )
          {
            e.printStackTrace();
          }
        }
      }

      Compile this using command: javac Test.java
      Compile the RMI-IIOP stubs and ties using: rmic -iiop Test
      Run the name server in the background using command: start tnameserv

      Run the program using command: java Test
      The following output is produced:

      java.lang.RuntimeException
              at com.sun.corba.se.internal.io.ObjectStreamClass.readResolve(Unknown Source)
              at com.sun.corba.se.internal.io.IIOPInputStream.simpleReadObject(Unknown Source)
              at com.sun.corba.se.internal.io.ValueHandlerImpl.readValueInternal(Unknown Source)
              at com.sun.corba.se.internal.io.ValueHandlerImpl.readValue(Unknown Source)
              at com.sun.corba.se.internal.iiop.CDRInputStream.read_value(Unknown Source)
              at com.sun.corba.se.internal.javax.rmi.CORBA.Util.copyObject(Unknown Source)
              at javax.rmi.CORBA.Util.copyObject(Unknown Source)
              at _Massive_Stub.getMass(Unknown Source)
              at Test.main(Test.java:26)
      java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
              java.rmi.MarshalException: CORBA MARSHAL 0 No; nested exception is:
              org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge : null minor code: 0 completed: No
      java.rmi.MarshalException: CORBA MARSHAL 0 No; nested exception is:
              org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge : null minor code: 0 completed: No
      org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge : null minor
       code: 0 completed: No
              <<no stack trace available>>

      This does not happen if the apparently ineffective Quantity.readResolve() method
      is removed.
      (Review ID: 100138)
      ======================================================================

            sbauersunw Stefan Bauer (Inactive)
            sgoodsunw Sheri Good (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: