gpt4 book ai didi

java.lang.NoClassDefFoundError : org/eclipse/jetty/server/nio/SelectChannelConnector using com. j256.simplejmx.web.JmxWebServer

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:14:15 25 4
gpt4 key购买 nike

我正在尝试使用com.j256.simplejmx 实现简单的JMX 客户端/服务器。我想使用 Web 浏览器监视我的对象。我复制了一段非常简单的代码:

package com.my.package.jmx;

import com.j256.simplejmx.web.JmxWebServer;

public class JMXServer {

public static void main(String[] args) throws Exception {

JmxWebServer jmxWebServer = new JmxWebServer(8123);
jmxWebServer.start();
}

}

当我运行它时出现异常:

Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/util/thread/ThreadPool
at com.my.package.jmx.JMXServer.main(JMXServer.java:9)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.util.thread.ThreadPool
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more

我将此添加到我的 pom.xml:

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>9.1.3.v20140225</version>
</dependency>

我再次运行它,我得到了另一个异常:

ception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/server/AbstractConnector
at com.my.package.jmx.JMXServer.main(JMXServer.java:9)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.AbstractConnector
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more

因此,我再次更新我的 pom.xml:

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.1.3.v20140225</version>
</dependency>

它再次给我一个错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/server/nio/SelectChannelConnector
at com.mu.package.jmx.JMXServer.main(JMXServer.java:9)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.nio.SelectChannelConnector
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more

我找不到任何解决方案。我还应该向我的 pom.xml 文件中添加什么?可能是依赖版本的问题?

提前谢谢你。


我编辑了我的pom.xml

<project...> 

<properties>
<jetty-version>8.1.9.v20130131</jetty-version>
</properties>

<dependencies>

<dependency>
<groupId>com.j256.simplejmx</groupId>
<artifactId>simplejmx</artifactId>
<version>1.8</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty-version}</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty-version}</version>
<optional>true</optional>
</dependency>

</dependencies>

</project>

现在,我可以运行这个服务器了:

INFO  Server - jetty-8.1.9.v20130131
INFO AbstractConnector - Started SelectChannelConnector@0.0.0.0:8123

但是当我进入我的网络浏览器并输入:

localhost:8123

它抛出一个异常:

WARN  nio - 
java.lang.SecurityException: class "javax.servlet.AsyncContext"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(Unknown Source)
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.jetty.server.AbstractHttpConnection.<init>(AbstractHttpConnection.java:157)
at org.eclipse.jetty.server.AsyncHttpConnection.<init>(AsyncHttpConnection.java:50)
at org.eclipse.jetty.server.nio.SelectChannelConnector.newConnection(SelectChannelConnector.java:285)
at org.eclipse.jetty.server.nio.SelectChannelConnector$ConnectorSelectorManager.newConnection(SelectChannelConnector.java:325)
at org.eclipse.jetty.server.nio.SelectChannelConnector.newEndPoint(SelectChannelConnector.java:272)
at org.eclipse.jetty.server.nio.SelectChannelConnector$ConnectorSelectorManager.newEndPoint(SelectChannelConnector.java:331)
at org.eclipse.jetty.io.nio.SelectorManager$SelectSet.createEndPoint(SelectorManager.java:841)
at org.eclipse.jetty.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:496)
at org.eclipse.jetty.io.nio.SelectorManager$1.run(SelectorManager.java:290)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)

最佳答案

Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.nio.SelectChannelConnector

所以现在SimpleJMX具有 8.1.9.v20130131 Jetty 的可选依赖项以支持 publishing JMX over web/HTTP .如果查看 pom.xml,您将看到:

<jetty-version>8.1.9.v20130131</jetty-version>
...
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty-version}</version>
<optional>true</optional>
</dependency>

你能试试这个版本的 Jetty 吗?我不确定是否有办法同时支持 8.X.X 和 9.X.X,但我会研究一下。

关于java.lang.NoClassDefFoundError : org/eclipse/jetty/server/nio/SelectChannelConnector using com. j256.simplejmx.web.JmxWebServer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22964880/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com