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

InvalidClassException in remote notification deserialization stops notifications

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4
    • 8
    • 6-pool
    • core-svc
    • b71
    • generic
    • generic

    Description

      FULL PRODUCT VERSION :
      java version "1.6.0_24"
      Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
      Java HotSpot(TM) Server VM (build 19.1-b02, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux eng20 2.6.16.60-0.39.3-smp #1 SMP Mon May 11 11:46:34 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      Assuming a server remotely exposing an MBean using the default RMI protocol, and this MBean sends notifications based on subclasses of javax.management.Notification.

      When a client connects to that server and registers a notification listener, everything works as expected as long as the client has the notification classes on its classpath. If it doesn't, notifications are dropped which is also fine.

      But when the client has a slightly changed notification class on its classpath (with a different serialVersionUID) an exception is logged and all notifications stop being propagated.

      Here's the logged exception:

      Mar 10, 2011 11:03:36 AM ClientNotifForwarder NotifFetcher-run
      SEVERE: Failed to fetch notification, stopping thread. Error is: java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
      java.io.InvalidClassException: demo.jmx.mbeans.IncNotif; local class incompatible: stream classdesc serialVersionUID = -6184530703350871710, local class serialVersionUID = 354054054054
      java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
      java.io.InvalidClassException: demo.jmx.mbeans.IncNotif; local class incompatible: stream classdesc serialVersionUID = -6184530703350871710, local class serialVersionUID = 354054054054
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:173)
      at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
      at javax.management.remote.rmi.RMIConnectionImpl_Stub.fetchNotifications(Unknown Source)
      at javax.management.remote.rmi.RMIConnector$RMINotifClient.fetchNotifs(RMIConnector.java:1306)
      at com.sun.jmx.remote.internal.ClientNotifForwarder$NotifFetcher.fetchNotifs(ClientNotifForwarder.java:554)
      at com.sun.jmx.remote.internal.ClientNotifForwarder$NotifFetcher.doRun(ClientNotifForwarder.java:437)
      at com.sun.jmx.remote.internal.ClientNotifForwarder$NotifFetcher.run(ClientNotifForwarder.java:418)
      at com.sun.jmx.remote.internal.ClientNotifForwarder$LinearExecutor$1.run(ClientNotifForwarder.java:88)
      Caused by: java.io.InvalidClassException: demo.jmx.mbeans.IncNotif; local class incompatible: stream classdesc serialVersionUID = -6184530703350871710, local class serialVersionUID = 354054054054
      at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
      at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
      at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1666)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1322)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
      at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:306)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:155)
      ... 7 more


      The exact same problem also occurs with the optional JMXMP protocol.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Write a JMX server with a simple MBean capable of sending notifications of a javax.management.Notification subclass.

      Write a JMX client connecting to the above server and registering a notification listener on the MBean. Make the special server notification's class available on the client's classpath but change the notification class' serialVersionUID. Make the server send a notification.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Un-deserializable notification should be dropped in the client, further notifications should continue to be propagated.
      ACTUAL -
      Notifications stop being propagated in the client.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Mar 10, 2011 11:03:36 AM ClientNotifForwarder NotifFetcher-run
      SEVERE: Failed to fetch notification, stopping thread. Error is: java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
      java.io.InvalidClassException: demo.jmx.mbeans.IncNotif; local class incompatible: stream classdesc serialVersionUID = -6184530703350871710, local class serialVersionUID = 354054054054
      java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
      java.io.InvalidClassException: demo.jmx.mbeans.IncNotif; local class incompatible: stream classdesc serialVersionUID = -6184530703350871710, local class serialVersionUID = 354054054054
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:173)
      at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
      at javax.management.remote.rmi.RMIConnectionImpl_Stub.fetchNotifications(Unknown Source)
      at javax.management.remote.rmi.RMIConnector$RMINotifClient.fetchNotifs(RMIConnector.java:1306)
      at com.sun.jmx.remote.internal.ClientNotifForwarder$NotifFetcher.fetchNotifs(ClientNotifForwarder.java:554)
      at com.sun.jmx.remote.internal.ClientNotifForwarder$NotifFetcher.doRun(ClientNotifForwarder.java:437)
      at com.sun.jmx.remote.internal.ClientNotifForwarder$NotifFetcher.run(ClientNotifForwarder.java:418)
      at com.sun.jmx.remote.internal.ClientNotifForwarder$LinearExecutor$1.run(ClientNotifForwarder.java:88)
      Caused by: java.io.InvalidClassException: demo.jmx.mbeans.IncNotif; local class incompatible: stream classdesc serialVersionUID = -6184530703350871710, local class serialVersionUID = 354054054054
      at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
      at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
      at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1666)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1322)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
      at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:306)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:155)
      ... 7 more


      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Make sure all notification classes are identical on client and server.

      Attachments

        Issue Links

          Activity

            People

              jbachorik Jaroslav BachorĂ­k
              emcmanus Eamonn McManus
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: