用于公开jmx方法的Camel自定义服务 - 例外:没有安全管理器:禁用了RMI类加载器

时间:2015-01-27 16:52:21

标签: security apache-camel rmi jmx

我成功添加了一个实现org.apache.camel.Service的自定义类来公开一些功能。返回void的所有方法都可以。现在我添加了一个返回String(多行)的方法。使用jconsole或MissionControl调用它会产生:

    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

由于我正在为jmx使用apache camel层,我问是否有一些骆驼方法来解决这个问题?

1 个答案:

答案 0 :(得分:1)

我认为你的新方法抛出了一个异常,例如javax.ws.rs.ProcessingException,它在被调用者端(例如来自jconsole等)不在类路径上。

也许尝试确保不会抛出任何异常并返回String值。也许甚至只是尝试硬编码并返回“Hello”等。如果有任何异常被抛出,那么只使用JDK本身的异常,这样你就不会有像这样的类路径问题。