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

Null pointer exception in DescriptorSupport.readObject()

XMLWordPrintable

        FULL PRODUCT VERSION :
        java version "1.5.0_04"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
        Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows XP [Version 5.1.2600]

        A DESCRIPTION OF THE PROBLEM :
        While using jconsole, i encountered problems displaying certain mbeans. JConsole simply reported "problem displaying mbean" and there was generally no additional information although it would occasionally provide a small stack trace for the UI code.

        I downloaded the JDK 1.5 source and debugged to determine the problem. I found that javax.management.modelmbean.DescriptorSupport.readObject() was failing with a NullPointerException if the following statement returned a null value.

        Map descriptor = (Map) fields.get("descriptor", null);

        The subsequent code invokes a method on descriptor regardless of whether it's null, triggering a null value exception for mbean attributes that return null in this call.

        Perhaps the mbean that I'm failing on shouldn't be generating a null value in this circumstance and I'm pursuing it from my end. But the failure of the JDK to handle the null value is causing jconsole to fail to display the mbean at all beyond providing a cryptic message.



        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        This only fails for certain mbeans when displayed in jconsole. I can reproduce the problem consistently when I try to display the JBoss TreeCache mbean remotely via jconsole. Other JBoss mbeans work properly in jconsole.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        I expect to see the mbean's attributes in jconsole. If an attribute fails for some reason (class notfound or not serializable), I expect to see "unavailable" for the attribute. For this particular mbean, the NullPointerException prevents jconsole from displaying the mbean at all.
        ACTUAL -
        JConsole message box indicating "problem displaying mbean."

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        Note - this stack trace was produced by adding printStackTrace code to an exception handler in DescriptorSupport.readObject(). The line numbers will differ slightly from the actual source code due to my use of System outs in the original code.

        XSheet.display.run
        caught mbean error: java.lang.NullPointerException
        java.lang.NullPointerException
                at javax.management.modelmbean.DescriptorSupport.readObject(DescriptorSu
        pport.java:1360)
                at sun.reflect.GeneratedMethodAccessor41.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
        sorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:919
        )
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1813)

                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
        713)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
                at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:19
        12)
                at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:46
        8)
                at javax.management.modelmbean.ModelMBeanAttributeInfo.readObject(ModelM
        BeanAttributeInfo.java:514)
                at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
        sorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:919
        )
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1813)

                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
        713)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
                at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1628)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1293)
                at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:19
        12)
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)

                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
        713)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
                at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
                at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:290)
                at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:139)
                at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
                at javax.management.remote.rmi.RMIConnectionImpl_Stub.getMBeanInfo(Unkno
        wn Source)
                at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.
        getMBeanInfo(RMIConnector.java:1028)
                at sun.tools.jconsole.inspector.XMBean.getMBeanInfo(XMBean.java:194)
                at sun.tools.jconsole.inspector.XSheet$2.run(XSheet.java:225)
                at sun.tools.jconsole.Worker.run(Worker.java:37)
        Exception in thread "Worker-MBeans-3860@localhost" java.lang.NullPointerExceptio
        n
                at java.awt.Container.addImpl(Container.java:1015)
                at java.awt.Container.add(Container.java:899)
                at sun.tools.jconsole.inspector.XSheet.updatePanel(XSheet.java:269)
                at sun.tools.jconsole.inspector.XSheet.access$8(XSheet.java:264)
                at sun.tools.jconsole.inspector.XSheet$2.run(XSheet.java:259)
                at sun.tools.jconsole.Worker.run(Worker.java:37)


        REPRODUCIBILITY :
        This bug can be reproduced always.
        Update:
        "I'm not sure whether the JBoss code is the issue here. After reporting the problem, I subsequently determined that the underlying issue was a classpath problem in the jconsole process (not in the JBoss process). Once I temporarily fixed the null pointer exception (by simply exiting the DescriptorSupport.readObject method), I encountered a ClassNotFound exception for a class in XercesImpl.jar. This was presumably triggered because the two JBoss mbeans which failed in jconsole both had DOM elements as attributes.

        After further investigation, I found that the classpath problem was the underlying cause. If I fixed the classpath by adding XercesImpl.jar to my jconsole classpath, the null pointer exception never occurred. But the classpath exception is only emitted to the JVM console if the null pointer is handled."

              sjiang Shanliang Jiang (Inactive)
              emcmanus Eamonn McManus
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: