我发现了类似的问题并没有解决我的问题 . 我创建了一个MBean接口及其Implementation类 . 我想在远程进程上创建这个MBean并调用它的方法 . 当我尝试 mBeanServer.registerMBean(diskSpace, beanName); 时,这适用于本地进程
但是当我在JMXConnector上使用MBeanServerConnection在远程服务器上创建相同内容时出错: -
mBeanServerConnection.createMBean(CheckDiskSpace.class.getName(), beanName);

这是整个堆栈跟踪: -

异常在线程“主要” javax.management.ReflectionException:在com.sun.jmx的MBean类不能由在com.sun.jmx.mbeanserver.MBeanInstantiator.findClassWithDefaultLoaderRepository(MBeanInstantiator.java:104)的默认加载器存储库加载.interceptor.DefaultMBeanServerInterceptor.createMBean(DefaultMBeanServerInterceptor.java:268)位于com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.createMBean(DefaultMBeanServerInterceptor.java:206)的com.sun.jmx.mbeanserver.JmxMBeanServer.createMBean(JmxMBeanServer.java:326) )在javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1425)在javax.management.remote.rmi.RMIConnectionImpl.access $ 300(RMIConnectionImpl.java:76)在javax.management.remote.rmi.RMIConnectionImpl $ PrivilegedOperation.run(RMIConnectionImpl.java:1311)在javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1403)在javax.management.remote.rmi.RMIConnectionImpl.createMBean(RMIConnectionImpl .java:259)在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:497)at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)at sun.rmi.transport.Transport $ 1.run(Transport.java:200)at sun.rmi.transport.Transport $ 1.run(Transport.java:197)位于sun.rmi的sun.rmi.transport.Transport.serviceCall(Transport.java:196)的java.security.AccessController.doPrivileged(Native Method) .transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)在sun.rmi.transport.tcp.TCPTransport $ ConnectionHandler.run0(TCPTransport.java:826)在sun.rmi.transport.tcp.TCPTransport $ ConnectionHandler.lambda $ run $ 79(TCPTransport.java:683)at sun.rmi.transport.tcp.TCPTransport $ ConnectionHandler $$ Lambda $ 46 / 1217272183.run(Unknown Source)at java.security.AccessController.doPrivile ged(Native Method)位于java.util.concurrent的java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)的sun.rmi.transport.tcp.TCPTransport $ ConnectionHandler.run(TCPTransport.java:682) . 的ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)在java.lang.Thread.run(Thread.java:745)在sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:283)在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位于com.walmart.healthcheck.diskspace.remote.JMXCheckDiskSpaceServer.jmxCheckDiskSpaceServer(JMXCheckDiskSpaceServer)的javax.management.remote.rmi.RMIConnector $ RemoteMBeanServerConnection.createMBean(RMIConnector.java:651)上的.remote.rmi.RMIConnectionImpl_Stub.createMBean(未知来源) . java:34)at com.walmart.healthcheck.diskspace.remote.RunJMX.main(RunJMX.java:18)引起:java.lan g.ClassNotFoundException:com.sun.jmx.mbeanserver.ClassLoaderRepositorySupport.loadClass(ClassLoaderRepositorySupport.java:232)中com.sun.jmx.mbeanserver.ClassLoaderRepositorySupport.loadClass(ClassLoaderRepositorySupport.java:144)中的com.walmart.healthcheck.diskspace.CheckDiskSpace )com.sun.jmx.mbean服务器上的com.sun.jmx.mbeanserver.MBeanInstantiator.findClassWithDefaultLoaderRepository(MBeanInstantiator.java:101)中的com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.createMBean(DefaultMBeanServerInterceptor.java:268)位于com.sun.jmx.interceptor.DefaultMBeanServerInterceptor . 位于javax.management的javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1425)的com.sun.jmx.mbeanserver.JmxMBeanServer.createMBean(JmxMBeanServer.java:326)中的createMBean(DefaultMBeanServerInterceptor.java:206) .remote.rmi.RMIConnectionImpl.access $ 300(RMIConnectionImpl.java:76)at atjavax.management.remote.rmi.RMIConnectionImpl $ PrivilegedOperation.run(RMIConnectionImpl.java:1311)位于javax.management.remote.rmi.RMIConnectionImpl的javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1403) . 在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)的sun.reflect.NativeMethodAccessorImpl.invoke0(本地方法)中的createMBean(RMIConnectionImpl.java:259)在sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)的sun.rmi.transport.Transport $ 1.run(Transport.java:)的java.lang.reflect.Method.invoke(Method.java:497) 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 at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)at sun.rmi.transport.tcp.TCPTransport $ Con nectionHandler.run0(TCPTransport.java:826)at sun.rmi.transport.tcp.TCPTransport $ ConnectionHandler.lambda $ run $ 79(TCPTransport.java:683)at sun.rmi.transport.tcp.TCPTransport $ ConnectionHandler $$ Lambda $ 46 /1217272183.run(Unknown Source)at java.security.AccessController.doPrivileged(Native Method)at sun.rmi.transport.tcp.TCPTransport $ ConnectionHandler.run(TCPTransport.java:682)at java.util.concurrent.ThreadPoolExecutor . runWorker(ThreadPoolExecutor.java:1142)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)at java.lang.Thread.run(Thread.java:745)

如何在远程进程上创建此MBean?我已经尝试单独创建MBean类,并在我的类中包含jar文件 .