Pradeep Jawahar
Pradeep Jawahar

Reputation: 495

Java RMI UnmarsharledException in tomcat web application

I am trying to query a JMX MBeanServer running in a Tomcat WebApplication. I'm seeing the following error while getting the list of attributes for a MBean

java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
    java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.apache.catalina.core.StandardContext
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:191)
    at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
    at javax.management.remote.rmi.RMIConnectionImpl_Stub.getAttributes(Unknown Source)
    at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.getAttributes(RMIConnector.java:927)

Am I doing anything wrong in my web application. I have tested my JMX client against many other java apps and have never come across this error. Will be helpful if someone has already come across this exception.

edit:

Found the bug

Bean: Catalina:name="ajp-bio-8009",type=ThreadPool
~~~~~
Attributes
.....
maxThreads:200
sSLEnabled:false
keystorePass:null
localPort:8009
connectionCount:1
currentThreadCount:0
keepAliveTimeout:-1
threadPriority:5
keyPass:null
useComet:false
soLinger:-1
sslEnabledProtocolsArray:[Ljava.lang.String;@3d1a70a7
socketProperties:java.rmi.UnmarshalException: error unmarshalling
...
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.apache.tomcat.util.net.SocketProperties

Upvotes: 0

Views: 1419

Answers (2)

user207421
user207421

Reputation: 311023

Your getAttributes() method returns a type StandardContext which is neither Serializable nor an exported remote object. So when the server went to write the return value, it incurred a NotSerializableException.

You seem to be trying to get the application context or its attributes remotely?

Upvotes: 2

user2860053
user2860053

Reputation:

Form this link:

http://docs.oracle.com/javase/7/docs/api/java/rmi/UnmarshalException.html

public class UnmarshalException
extends RemoteException

An UnmarshalException can be thrown while unmarshalling the parameters or results of a remote method call if any of the following conditions occur:

  • If an exception occurs while unmarshalling the call header
  • if the protocol for the return value is invalid
  • if a java.io.IOException occurs unmarshalling parameters (on the server side) or the return value (on the client side).
  • if a java.lang.ClassNotFoundException occurs during unmarshalling parameters or return values
  • if no skeleton can be loaded on the server-side; note that skeletons are required in the 1.1 stub protocol, but not in the 1.2 stub protocol.
  • if the method hash is invalid (i.e., missing method).
  • if there is a failure to create a remote reference object for a remote object's stub when it is unmarshalled.

Upvotes: 2

Related Questions