Search code examples
securityapache-camelrmijmx

Camel custom service to expose jmx methods - Exception: no security manager: RMI class loader disabled


i successfully added a custom class that implements org.apache.camel.Service to expose some functionality. All methods returning void work fine. Now i added a method that returns a String (multiple lines). Calling this with jconsole or MissionControl yields:

    java.rmi.UnmarshalException: Error unmarshaling return; nested exception is: 
    java.lang.ClassNotFoundException: javax.ws.rs.ProcessingException (no security manager: RMI class loader disabled)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:246)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:161)
    at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
    at javax.management.remote.rmi.RMIConnectionImpl_Stub.invoke(Unknown Source)
    at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.invoke(RMIConnector.java:1029)
    at com.jrockit.mc.rjmx.internal.MCMBeanServerConnection.invoke(MCMBeanServerConnection.java:234)
    at com.jrockit.mc.rjmx.services.internal.MBeanOperationsWrapper$MBeanOperation$1.call(MBeanOperationsWrapper.java:133)
    at com.jrockit.mc.rjmx.ui.operations.ExecuteOperationForm.createInvocationResult(ExecuteOperationForm.java:143)
    at com.jrockit.mc.rjmx.ui.operations.ExecuteOperationForm.access$9(ExecuteOperationForm.java:138)
    at com.jrockit.mc.rjmx.ui.operations.ExecuteOperationForm$3.widgetSelected(ExecuteOperationForm.java:125)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at com.jrockit.mc.rcp.application.Application.start(Application.java:26)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
Caused by: java.lang.ClassNotFoundException: javax.ws.rs.ProcessingException (no security manager: RMI class loader disabled)
    at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:393)
    at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:185)
    at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:637)
    at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:264)
    at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:214)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1612)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:244)
    ... 35 more

Since i am using the apache camel layer for jmx i ask if there is some camel way to fix this?


Solution

  • I think your new method throws an exception such as javax.ws.rs.ProcessingException which on the callee side (eg from jconsole etc) is not on the classpath.

    Maybe try to ensure no exception is thrown and that a String value is returned. Maybe even try just to hardcode and return "Hello" etc. And if any exceptions is supposedly to be thrown then favor only using exceptions from the JDK itself so you wont have classpath issues like this.