quartz使用jmx报ClassNotFoundException

发布于 2021-12-02 02:27:19 字数 5812 浏览 824 评论 1

Quartz启用jmx,启动注册成功,但客户端连接时报错
server:
org.quartz.scheduler.jmx.export = true
org.quartz.scheduler.jmx.objectName = jmxBean:name=task
org.quartz.scheduler.rmi.export = true
org.quartz.scheduler.rmi.registryHost = 192.168.1.1
org.quartz.scheduler.rmi.registryPort = 1099
org.quartz.scheduler.rmi.createRegistry = as_needed
org.quartz.scheduler.rmi.bindName = TaskInfo

client:
public static void main(String[] args) throws Exception {
  String rmiUrl = "service:jmx:rmi:///jndi/rmi://192.168.1.1:1099/TaskInfo";
  String cfgTaskId = "1000";
  System.out.println(rmiUrl);
  System.out.println(cfgTaskId);
  System.setSecurityManager (new RMISecurityManager() {
   public void checkConnect (String host, int port) {}
   public void checkConnect (String host, int port, Object context) {}
  });

  JMXServiceURL url = new JMXServiceURL(rmiUrl);

        JMXConnector jmxc = JMXConnectorFactory.connect(url,null);

        MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();      

        ObjectName mbeanName = new ObjectName("jmxBean:name=task");   
       
 }
 
报错如下:
Exception in thread "main" java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
        java.lang.ClassNotFoundException: org.quartz.core.QuartzScheduler_Stub]
        at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:369)
        at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:270)
        at jmx.JmxTest.main(JmxTest.java:33)
Caused by: javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
        java.lang.ClassNotFoundException: org.quartz.core.QuartzScheduler_Stub]
        at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:122)
        at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:205)
        at javax.naming.InitialContext.lookup(InitialContext.java:417)
        at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1957)
        at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1924)
        at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:287)
        ... 2 more
Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
        java.lang.ClassNotFoundException: org.quartz.core.QuartzScheduler_Stub
        at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
        at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:118)
        ... 7 more
Caused by: java.lang.ClassNotFoundException: org.quartz.core.QuartzScheduler_Stub
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.rmi.server.LoaderHandler$Loader.loadClass(LoaderHandler.java:1207)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at sun.rmi.server.LoaderHandler.loadClassForName(LoaderHandler.java:1221)
        at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:453)
        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:214)
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1613)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
        ... 9 more

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

想挽留 2021-12-04 01:09:46

这个应该是服务端类找不到

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文