0

I am new to JMX. I am using Spring 4 with JMX. I am also using Apache Camel and would like to expose a stop method. I have setup everything but when clicking on the stop method within MBeans in JConsole I get the following Exception:

Problem invoking stop : java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.io.WriteArbortedException:writing aborted:java.io.NotSerializableException: org.apache.camel.spring.SpringCamelContext

The project is located on GitHub: https://github.com/rajivj2/example2/

The class for the MBean code is located is in com.example.config.ApacheCamelConfig.java

Once the project is build using mvn clean install run the following on the Command Prompt:

java -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -jar server-app-jar-with-dependencies.jar

After this in the Java JDK bin folder open jconsole and connect to the server-app-jar-with-dependencies.jar. Locate the MBeans tab and the stop method.

I can't see where I am going wrong. The SpringCamelContext is provided by Apache Camel.

user
  • 81
  • 1
  • 1
  • 9

1 Answers1

0

you should not return the CamelContext - it is not serializable.

separate the @Bean from the @ManagedOperation - the operation for stopping the route should have return type void

Elyran
  • 313
  • 2
  • 10