This is the JMX bean invoke (that fails) :
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.ws.rs.core.Response;
MBeanServerConnection mbeanConn
//some code going on ...
...
response = (Response) mbeanConn.invoke(myBean,"example", null, null);
It throws the exception :
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.apache.cxf.jaxrs.impl.ResponseIm
When looking in my code the function that is invoked is :
import javax.ws.rs.core.Response;
@ManagedOperation
public Response example() throws GeneralException {
//do some things with the response object
...
return response.build();
}
From my understanding I have a problem that the abstract class javax.ws.rs.core.Response isn't Serialized.
Any ideas how to bypass this problem ?
JMX uses java serialization to transfer arguments and operation results. Even if the class was
Serializable
you'd need it on the client's classpath.There is no solution except adding an operation that renders the object as, say, a String. If you are lucky, you can use
toString()
but if the object hasn't overriddenObject.toString()
, you'll have to roll your own.