JMX and MBean serialVersionUID problem

Hi.

I have instrumented a web based application with MBeans and also written its own JMX connector server that will allow external clients to connect to it. I am deploying the application on Websphere Application Server version 5.x. Now the problem is that when I connect using MC4J console, it throws the following error message :-

java.lang.reflect.UndeclaredThrowableException

at $Proxy10.queryNames(Unknown Source)

at org.mc4j.console.connection.ConnectionNode.loadConnectionNodeChildren(ConnectionNode.java:207)

at org.mc4j.console.connection.ConnectionNode.connect(ConnectionNode.java:517)

at org.mc4j.console.connection.JSR160ConnectionNode.connect(JSR160ConnectionNode.java:144)

at org.mc4j.console.connection.ReconnectAction.performAction(ReconnectAction.java:47)

at org.openide.util.actions.NodeAction$3.run(NodeAction.java:440)

at org.openide.util.actions.CallableSystemAction$ActionRunnable.actionPerformed(CallableSystemAction.java:247)

at org.netbeans.core.ModuleActions.invokeAction(ModuleActions.java:74)

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:324)

at org.openide.util.actions.CallableSystemAction.invokeAction(CallableSystemAction.java:179)

at org.openide.util.actions.CallableSystemAction.access$000(CallableSystemAction.java:31)

at org.openide.util.actions.CallableSystemAction$ActionRunnable.doRun(CallableSystemAction.java:241)

at org.openide.util.actions.CallableSystemAction$2.run(CallableSystemAction.java:111)

at org.openide.util.Task.run(Task.java:136)

at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:330)

at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:686)

Caused by: java.lang.reflect.InvocationTargetException

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:324)

at org.mc4j.console.connection.proxy.JMXRemotingMBeanServerProxy.invoke(JMXRemotingMBeanServerProxy.java:61)

... 19 more

Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested exception is:

java.io.InvalidClassException: javax.management.ObjectName; local class incompatible: stream classdesc serialVersionUID = -5467795090068647408, local class serialVersionUID = 1081892073854801359

at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:164)

at javax.management.remote.rmi.RMIConnectionImpl_Stub.queryNames(Unknown Source)

at mx4j.remote.rmi.ClientInvoker.queryNames(ClientInvoker.java:265)

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:324)

at mx4j.remote.ClientProxy.invoke(ClientProxy.java:32)

at mx4j.remote.rmi.ClientUnmarshaller.chain(ClientUnmarshaller.java:65)

at mx4j.remote.rmi.ClientUnmarshaller.invoke(ClientUnmarshaller.java:54)

at $Proxy9.queryNames(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:324)

at mx4j.remote.ClientProxy.invoke(ClientProxy.java:32)

at mx4j.remote.rmi.ClientExceptionCatcher.invoke(ClientExceptionCatcher.java:40)

at $Proxy9.queryNames(Unknown Source)

... 24 more

Caused by: java.io.InvalidClassException: javax.management.ObjectName; local class incompatible: stream classdesc serialVersionUID = -5467795090068647408, local class serialVersionUID = 1081892073854801359

at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:463)

at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)

at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)

at java.util.HashSet.readObject(HashSet.java:276)

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:324)

at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:838)

at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1746)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)

at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:297)

at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:146)

[catch] ... 41 more

==>

java.lang.reflect.InvocationTargetException

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:324)

at org.mc4j.console.connection.proxy.JMXRemotingMBeanServerProxy.invoke(JMXRemotingMBeanServerProxy.java:61)

at $Proxy10.queryNames(Unknown Source)

at org.mc4j.console.connection.ConnectionNode.loadConnectionNodeChildren(ConnectionNode.java:207)

at org.mc4j.console.connection.ConnectionNode.connect(ConnectionNode.java:517)

at org.mc4j.console.connection.JSR160ConnectionNode.connect(JSR160ConnectionNode.java:144)

at org.mc4j.console.connection.ReconnectAction.performAction(ReconnectAction.java:47)

at org.openide.util.actions.NodeAction$3.run(NodeAction.java:440)

at org.openide.util.actions.CallableSystemAction$ActionRunnable.actionPerformed(CallableSystemAction.java:247)

at org.netbeans.core.ModuleActions.invokeAction(ModuleActions.java:74)

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:324)

at org.openide.util.actions.CallableSystemAction.invokeAction(CallableSystemAction.java:179)

at org.openide.util.actions.CallableSystemAction.access$000(CallableSystemAction.java:31)

at org.openide.util.actions.CallableSystemAction$ActionRunnable.doRun(CallableSystemAction.java:241)

at org.openide.util.actions.CallableSystemAction$2.run(CallableSystemAction.java:111)

at org.openide.util.Task.run(Task.java:136)

at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:330)

at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:686)

Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested exception is:

java.io.InvalidClassException: javax.management.ObjectName; local class incompatible: stream classdesc serialVersionUID = -5467795090068647408, local class serialVersionUID = 1081892073854801359

at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:164)

at javax.management.remote.rmi.RMIConnectionImpl_Stub.queryNames(Unknown Source)

at mx4j.remote.rmi.ClientInvoker.queryNames(ClientInvoker.java:265)

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:324)

at mx4j.remote.ClientProxy.invoke(ClientProxy.java:32)

at mx4j.remote.rmi.ClientUnmarshaller.chain(ClientUnmarshaller.java:65)

at mx4j.remote.rmi.ClientUnmarshaller.invoke(ClientUnmarshaller.java:54)

at $Proxy9.queryNames(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:324)

at mx4j.remote.ClientProxy.invoke(ClientProxy.java:32)

at mx4j.remote.rmi.ClientExceptionCatcher.invoke(ClientExceptionCatcher.java:40)

at $Proxy9.queryNames(Unknown Source)

... 24 more

Caused by: java.io.InvalidClassException: javax.management.ObjectName; local class incompatible: stream classdesc serialVersionUID = -5467795090068647408, local class serialVersionUID = 1081892073854801359

at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:463)

at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)

at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)

at java.util.HashSet.readObject(HashSet.java:276)

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:324)

at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:838)

at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1746)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)

at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:297)

at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:146)

[catch] ... 41 more

==>

java.rmi.UnmarshalException: error unmarshalling return; nested exception is:

java.io.InvalidClassException: javax.management.ObjectName; local class incompatible: stream classdesc serialVersionUID = -5467795090068647408, local class serialVersionUID = 1081892073854801359

at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:164)

at javax.management.remote.rmi.RMIConnectionImpl_Stub.queryNames(Unknown Source)

at mx4j.remote.rmi.ClientInvoker.queryNames(ClientInvoker.java:265)

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:324)

at mx4j.remote.ClientProxy.invoke(ClientProxy.java:32)

at mx4j.remote.rmi.ClientUnmarshaller.chain(ClientUnmarshaller.java:65)

at mx4j.remote.rmi.ClientUnmarshaller.invoke(ClientUnmarshaller.java:54)

at $Proxy9.queryNames(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:324)

at mx4j.remote.ClientProxy.invoke(ClientProxy.java:32)

at mx4j.remote.rmi.ClientExceptionCatcher.invoke(ClientExceptionCatcher.java:40)

at $Proxy9.queryNames(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:324)

at org.mc4j.console.connection.proxy.JMXRemotingMBeanServerProxy.invoke(JMXRemotingMBeanServerProxy.java:61)

at $Proxy10.queryNames(Unknown Source)

at org.mc4j.console.connection.ConnectionNode.loadConnectionNodeChildren(ConnectionNode.java:207)

at org.mc4j.console.connection.ConnectionNode.connect(ConnectionNode.java:517)

at org.mc4j.console.connection.JSR160ConnectionNode.connect(JSR160ConnectionNode.java:144)

at org.mc4j.console.connection.ReconnectAction.performAction(ReconnectAction.java:47)

at org.openide.util.actions.NodeAction$3.run(NodeAction.java:440)

at org.openide.util.actions.CallableSystemAction$ActionRunnable.actionPerformed(CallableSystemAction.java:247)

at org.netbeans.core.ModuleActions.invokeAction(ModuleActions.java:74)

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:324)

at org.openide.util.actions.CallableSystemAction.invokeAction(CallableSystemAction.java:179)

at org.openide.util.actions.CallableSystemAction.access$000(CallableSystemAction.java:31)

at org.openide.util.actions.CallableSystemAction$ActionRunnable.doRun(CallableSystemAction.java:241)

at org.openide.util.actions.CallableSystemAction$2.run(CallableSystemAction.java:111)

at org.openide.util.Task.run(Task.java:136)

at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:330)

at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:686)

Caused by: java.io.InvalidClassException: javax.management.ObjectName; local class incompatible: stream classdesc serialVersionUID = -5467795090068647408, local class serialVersionUID = 1081892073854801359

at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:463)

at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)

at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)

at java.util.HashSet.readObject(HashSet.java:276)

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:324)

at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:838)

at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1746)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)

at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:297)

at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:146)

[catch] ... 41 more

I know what this error means. WAS 5.x uses Tivoli JMX and MC4J uses MX4J, and thus their serialVersionUIDs dont match during deserialization at MC4J's end. But the problem is that I also have compiled my mbeans using MX4J API. Then why this problem still comes? Any ideas?

Message was edited by:

AUTOMATON

[16561 byte] By [AUTOMATONa] at [2007-11-26 18:59:47]
# 1

Hi,

It looks like your server application is using an older version of JMX, probably 1.0.

Try to start your client process with the following property on the command line:

-Djmx.serial.form=1.0

Hope this helps,

-- daniel

JMX, SNMP, Java, etc...

http://blogs.sun.com/jmxetc

dfuchsa at 2007-7-9 20:41:21 > top of Java-index,Core,Monitoring & Management...
# 2

Thanks for the reply. However, I am using jdk1.4 so setting this property will not work for me. What I dont understand is that I have explicitly pointed to my mx4j JARs in the MANIFEST.MF file in my web app, and during runtime it still uses com.tivoli.jmx.MBeanServer instead of javax.management.MBeanServer. How can I make use of mx4j libs at runtime. I even have made the entries of mx4j libs in the CLASSPATH env variable, and they are the FIRST entries there!

AUTOMATONa at 2007-7-9 20:41:21 > top of Java-index,Core,Monitoring & Management...
# 3

Hi,

1) I have done a little research. The property will work if use Sun's JMX 1.2 reference

implementation on the client side, but apparently MX4J does not support this

property. However the gust of the problem is that in JMX 1.0, some serial forms

where not defined by the spec, so there is no guarantee that different implementation

of JMX 1.0 (such as that from Weblogic and that from Sun) will be able to interoperate.

This has been fixed in JMX 1.1, and the jmx.serial.form=1.0 was added to allow

interoperability with *JMX 1.0 Reference Implementation*.

The Sun JMX reference implementations (JMX 1.1. and JMX 1.2 RIs) support this

property, but other implementations are not required to support it.

See point A.15 in:

http://www.jcp.org/aboutJava/communityprocess/maintenance/jsr003/jmx1.2-change-log.txt

However using that property may allow a Sun JMX RI to interoperate with Weblogic 1.0

implementation.

2) I don't think it's possible to force your application server to use a newer version of

JMX. I believe the only way to do that is to upgrade your application server. However

I am not from IBM so I may be wrong about that - it's a question you should ask

to Websphere support.

more info:

http://jcp.org/aboutJava/communityprocess/maintenance/jsr003/final_list.html

http://weblogs.java.net/blog/emcmanus/archive/2005/07/dealing_with_mu.html

Hope this helps,

-- daniel

JMX, SNMP, Java, etc...

http://blogs.sun.com/jmxetc

dfuchsa at 2007-7-9 20:41:22 > top of Java-index,Core,Monitoring & Management...
# 4

Thanks a lot to actually going to the pains for doing some research on this. You have no idea how much a appreciate it! :))

Actually I was succesfull in solving this problem. There is a property in Websphere which you must set that controls the Class loading for a enterprise application. That solved my problem completely. I set it to "PARENT_LAST" which forces Websphere to refer JMX1.2 jars insteasd of those dirty tivoli JARS.

As for MX4J and SUN RI incompatibilyt, I also suspected that, but I checked it out with writing some code (client = mx4j) (server=jmxri) and vise versa, and it seems to work perfectly without any errors.

AUTOMATONa at 2007-7-9 20:41:22 > top of Java-index,Core,Monitoring & Management...
# 5

Hi,

There is no incompatibility between MX4J and Sun's JMX API RI because they are

two implementations of *the same* specification - JMX API 1.2 + JMX Remote API 1.0 (aka JSR 160).

The purpose of JSR 160 was precisely to make sure that two independent implementations

of the JMX Remote API 1.0 are able to interoperate. Furthermore the Sun JMX Remote API RI 1.0

jars have *no dependency* on Sun's JMX 1.2 private RI classes - so they will work on top

of any implementation of JMX 1.2.

As I already explained in <a href="http://blogs.sun.com/jmxetc/entry/easy_is_not_always_simple">one of my blogs</a>, the version 1.0 of the JMX API had no remote

API - and the specification had left the serial form undefined. It is thus difficult to

interoperate with an implementation of JMX 1.0 - unless you know which implementation

it is and what serial form it uses.

The JMX API 1.2 + JMX Remote API 1.0 specifications have corrected these mistakes.

Hope this helps,

-- daniel

JMX, SNMP, Java, etc...

http://blogs.sun.com/jmxetc

dfuchsa at 2007-7-9 20:41:22 > top of Java-index,Core,Monitoring & Management...