gpt4 book ai didi

java - ServletException : ClassNotFoundException org. eclipse.jetty.websocket.server.WebSocketServerFactory

转载 作者:行者123 更新时间:2023-11-30 08:09:40 24 4
gpt4 key购买 nike

我设置了一个 Websocket 服务器,它应该运行一个由 websocket servlet 工厂创建的 servlet。
但是,每当我尝试通过我最喜欢的浏览器访问 websocket 时,我都会得到

HTTP ERROR: 500

Problem accessing /test/sound. Reason:

javax.servlet.ServletException: java.lang.ClassNotFoundException: org.eclipse.jetty.websocket.server.WebSocketServerFactory

服务器控制台给出了类似的错误。下面是完整的控制台错误消息:

    [13:21:26 WARN]: 2015-08-27 13:21:26.912:WARN:/test:qtp20972561-41: unavailable
java.lang.ClassNotFoundException: org.eclipse.jetty.websocket.server.WebSocketSe
rverFactory
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.websocket.servlet.WebSocketServletFactory$Loader.lo
ad(WebSocketServletFactory.java:63)
at org.eclipse.jetty.websocket.servlet.WebSocketServletFactory$Loader.cr
eate(WebSocketServletFactory.java:42)
at org.eclipse.jetty.websocket.servlet.WebSocketServlet.init(WebSocketSe
rvlet.java:128)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.jav
a:612)
at org.eclipse.jetty.servlet.ServletHolder.getServlet(ServletHolder.java
:468)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:778
)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java
:587)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandl
er.java:1125)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:
515)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandle
r.java:1059)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j
ava:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper
.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:497)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.jav
a:248)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java
:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPoo
l.java:620)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool
.java:540)
at java.lang.Thread.run(Unknown Source)
[13:21:26 WARN]: 2015-08-27 13:21:26.913:WARN:oejs.ServletHandler:qtp20972561-41
:
javax.servlet.ServletException: java.lang.ClassNotFoundException: org.eclipse.je
tty.websocket.server.WebSocketServerFactory
at org.eclipse.jetty.websocket.servlet.WebSocketServlet.init(WebSocketSe
rvlet.java:138)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.jav
a:612)
at org.eclipse.jetty.servlet.ServletHolder.getServlet(ServletHolder.java
:468)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:778
)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java
:587)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandl
er.java:1125)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:
515)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandle
r.java:1059)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j
ava:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper
.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:497)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.jav
a:248)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java
:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPoo
l.java:620)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool
.java:540)
at java.lang.Thread.run(Unknown Source)
Caused by:
java.lang.ClassNotFoundException: org.eclipse.jetty.websocket.server.WebSocketSe
rverFactory
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.websocket.servlet.WebSocketServletFactory$Loader.lo
ad(WebSocketServletFactory.java:63)
at org.eclipse.jetty.websocket.servlet.WebSocketServletFactory$Loader.cr
eate(WebSocketServletFactory.java:42)
at org.eclipse.jetty.websocket.servlet.WebSocketServlet.init(WebSocketSe
rvlet.java:128)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.jav
a:612)
at org.eclipse.jetty.servlet.ServletHolder.getServlet(ServletHolder.java
:468)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:778
)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java
:587)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandl
er.java:1125)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:
515)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandle
r.java:1059)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j
ava:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper
.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:497)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.jav
a:248)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java
:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPoo
l.java:620)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool
.java:540)
at java.lang.Thread.run(Unknown Source)

我最好的选择是,由于缺少 WebSocketServletFactory 类,我在 pom.xml 中忘记了一些东西,但我不确定。

这是我在 pom.xml 中的存储库和依赖项

<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>googlecode</id>
<name>jWebSocket Repository</name>
<url>http://jwebsocket.googlecode.com/svn/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.2.5.v20141112</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>9.2.5.v20141112</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>9.2.5.v20141112</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
</dependencies>

我该如何解决这个错误?如果需要更多来源,请提出要求。

最佳答案

我终于自己回答了我的问题。该问题可以通过将类路径添加到 META-INF/manifest.mf 文件中缺失的 jar 来解决。

也许我应该提到我试图通过 bukkit 插件在 minecraft 服务器上运行 jetty-server。现在工作正常。显然,这是将外部库添加到 bukkit 插件的正确方法。

感谢所有回答/评论的人。

关于java - ServletException : ClassNotFoundException org. eclipse.jetty.websocket.server.WebSocketServerFactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32248642/

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