你好研究员,
我正在尝试使用jvisualvm打开与应用程序的jmx连接,但是当我添加连接时,它会因SecurityException而失败。任何人都可以帮我弄明白我怎么能避免这种情况?
完整堆栈跟踪
SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor com.sun.tools.visualvm.jmx.impl.AddJMXConnectionAction$1 java.lang.SecurityException: attempt to add a Permission to a readonly Permissions object at java.security.Permissions.add(Permissions.java:126) at java.security.Policy$UnsupportedEmptyCollection.add(Policy.java:827) at sun.rmi.server.LoaderHandler.getLoaderAccessControlContext(LoaderHandler.java:1005) at sun.rmi.server.LoaderHandler.lookupLoader(LoaderHandler.java:881) at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:404) at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:186) 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:219) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1866) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1749) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2040) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1571) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:431) at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:322) at sun.rmi.server.UnicastServerRef.unmarshalParametersUnchecked(UnicastServerRef.java:628) at sun.rmi.server.UnicastServerRef.unmarshalParameters(UnicastServerRef.java:616) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:338) at sun.rmi.transport.Transport$1.run(Transport.java:200) at sun.rmi.transport.Transport$1.run(Transport.java:197) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:196) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:835) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:283) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:260) 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.isInstanceOf(Unknown Source) at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.isInstanceOf(RMIConnector.java:1100) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.tools.visualvm.jmx.impl.JmxModelImpl$CheckerInvocationHandler.invoke(JmxModelImpl.java:655) at com.sun.proxy.$Proxy11.isInstanceOf(Unknown Source) at java.lang.management.ManagementFactory.newPlatformMXBeanProxy(ManagementFactory.java:617) at com.sun.tools.visualvm.tools.jmx.JvmMXBeansFactory$JvmMXBeansImpl.getMXBean(JvmMXBeansFactory.java:363) at com.sun.tools.visualvm.tools.jmx.JvmMXBeansFactory$JvmMXBeansImpl.getRuntimeMXBean(JvmMXBeansFactory.java:336) at com.sun.tools.visualvm.jmx.impl.JmxApplication.getPid(JmxApplication.java:64) at com.sun.tools.visualvm.jvmstat.JvmstatModelProvider.getMonitoredVm(JvmstatModelProvider.java:29) at com.sun.tools.visualvm.jvmstat.JvmstatModelProvider.createModelFor(JvmstatModelProvider.java:51) at com.sun.tools.visualvm.jvmstat.JvmstatModelProvider.createModelFor(JvmstatModelProvider.java:25) at com.sun.tools.visualvm.core.model.ModelFactory.getModel(ModelFactory.java:91) at com.sun.tools.visualvm.tools.jvmstat.JvmstatModelFactory.getJvmstatFor(JvmstatModelFactory.java:45) at com.sun.tools.visualvm.jvm.JRockitJvmProvider.createModelFor(JRockitJvmProvider.java:29) at com.sun.tools.visualvm.jvm.JRockitJvmProvider.createModelFor(JRockitJvmProvider.java:22) at com.sun.tools.visualvm.core.model.ModelFactory.getModel(ModelFactory.java:91) at com.sun.tools.visualvm.application.jvm.JvmFactory.getJVMFor(JvmFactory.java:45) at com.sun.tools.visualvm.jmx.impl.JmxApplicationProvider.addJmxApplication(JmxApplicationProvider.java:303) at com.sun.tools.visualvm.jmx.impl.JmxApplicationProvider.createJmxApplication(JmxApplicationProvider.java:186) at com.sun.tools.visualvm.jmx.JmxApplicationsSupport.createJmxApplicationImpl(JmxApplicationsSupport.java:299) at com.sun.tools.visualvm.jmx.JmxApplicationsSupport.createJmxApplicationInteractive(JmxApplicationsSupport.java:276) at com.sun.tools.visualvm.jmx.impl.AddJMXConnectionAction$1.run(AddJMXConnectionAction.java:60) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1384) [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1994)
任何帮助赞赏。
你的应用程序代码中是否有SecurityManager?
@Override
public PermissionCollection getPermissions(ProtectionDomain domain) {}
可以返回不可变列表。在我的情况下,这导致了同样的例外。