JDK-6495529 : MBeans tab: NPE when handling Exception
  • Type: Bug
  • Component: tools
  • Sub-Component: jconsole
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-11-20
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u4Fixed 7 b05Fixed
Description
FULL PRODUCT VERSION :
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
This bug is OS independend

EXTRA RELEVANT SYSTEM CONFIGURATION :
I am using mx4j as server with JSR-160 generic connector.

A DESCRIPTION OF THE PROBLEM :
If the jconsole catches an exception (ex) from invoking an MBean it does
ex = Utils.getActualException(ex)
This method checks if the type of the exception. E.g. if it is an MBeanException, it calls getTargetException on that exception. However in my case this is null.
Maybe this is a violation of the JMX spec but anyhows this happens in some cases with the latest mx4j using burlap or hessian as transport protocol.
One line later the jconsole performs a toString on "ex" causing a NullPointerException in my case. This NPE goes through the complete Thread and stalls the complete JConsole.
Please add a check if the "actual exception" is null and then use the original exception catched instead of null.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. start a JMX Server using mx4j together with hessian or burlap
2. connect with jconsole -J-Djava.endorsed.dirs=... service:jmx:hessian://...
3. invoke an operation that throws an MBean exception

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The jconsole should open a dialog displaying the exception message.
ACTUAL -
The JConsole dumps the strack-trace below (see Error Message) and the MBean tab panel (Attributes, Operations, Notifications, Info) keeps completely disabled no matter what MBean you select in the MBeans tree.


ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "Worker-MBeans-myhost:8080" java.lang.NullPointerException
at sun.tools.jconsole.inspector.XMBeanAttributes$AttributesListener$1.run(XMBeanAttributes.java:786)
at sun.tools.jconsole.Worker.run(Worker.java:37)
Exception in thread "Worker-MBeans-wep06132:8080" java.lang.NullPointerException
at sun.tools.jconsole.inspector.XMBeanAttributes$AttributesListener$1.run(XMBeanAttributes.java:786)
at sun.tools.jconsole.Worker.run(Worker.java:37)

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
If I use an Introspector in the mx4j Server and convert all Exceptions to e.g. RuntimeException with the orignal message, the exception is properly handled by jconsole.

Comments
EVALUATION Check for non-null target exceptions before calling toString().
20-11-2006