views:

114

answers:

1

We are using JMX for communication between different EARs on the same Websphere application server (6.1). All works well if we only use Java types as arguments, but if we use our own classes as arguments the problem is that we get ClassCastExceptions on the receiver side. This is obviously a classloader problem: if the jar with the argument types is put into the JRE endorsed directory, such that all classloaders use exactly the same class, the exceptions disappear. But we would much prefer to put the library that defines the argument types in the EAR itself.

Now my question: is there a trick to persuade WAS to serialize and deserialize the arguments during the JMX call I guess in this case the ClassCastException would dissappear.

A: 

You are correct that this is a classloader problem, and that passing serialized objects as JMX call arguments would side-step the issue. But you could pay a significant performance penalty. Object serialization / deserialization is not cheap.

Stephen C
Right. But my question was: how do I persuade WAS to use serialization when executing a JMX call? It just seems to pass them by reference, which is causing trouble here.
hstoerr
Serialize the arguments by hand yourself and pass them as byte arrays?
Stephen C