Jetty 8 网络套接字
我已经下载了最新的 Jetty 8 Hightide,但无法使 WebSockets 工作。我解压缩发行版,将 .war 文件放入 webapps 文件夹中并启动:
java.lang.NoClassDefFoundError: org/eclipse/jetty/websocket/WebSocketServlet
我已验证 JETTY_HOME/lib 文件夹包含 jetty-websocket.jar 并且包含 WebSocketServlet 类文件。
我之前已经在里程碑版本中运行过这个。
I've downloaded the latest Jetty 8 Hightide, but cannot get WebSockets to work. I unzip the distribution, put my .war file in the webapps folder and start:
java.lang.NoClassDefFoundError: org/eclipse/jetty/websocket/WebSocketServlet
I've verified that the JETTY_HOME/lib folder contains the jetty-websocket.jar and it contains the WebSocketServlet class file.
I've had this running before with the milestone releases.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
由于某种原因,默认情况下 Web 套接字似乎不再可用,因此上下文 XML 文件中需要以下代码:
For some reason, it appears that web sockets are no longer available by default, so the following code is needed in the context XML file:
我使用 jetty-maven-plugin 和版本
8.0.3.v20111011
也经历了同样的事情。然而解决方案很简单。只需包含jetty-websocket作为编译范围依赖项(即不声明范围)。pom.xml
的相关部分:I experienced the same using jetty-maven-plugin and version
8.0.3.v20111011
. However the solution was simple. Just include thejetty-websocket
as a compiled scope dependency (i.e. don't declared scope).Relevant sections of
pom.xml
:似乎对我很有用!
Seemed to work great for me!
通过 WST 插件从 Eclipse 运行 Jetty 时遇到类似问题。这是我解决问题的方法。在工作区的 .metadata 目录下找到应用程序的上下文:[jetty install dir]/lib/jetty-websocket-8.1.2.v20120308.jar;[jetty install dir]/lib /jetty-util-8.1.2.v20120308.jar
[工作空间的 .metadata]/.plugins/org.eclipse.wst.server.core/[configuration id like 'tmp1']/contexts/[app name].xml 。
编辑它以在配置标签下包含以下内容:
必须对 Jetty 安装进行硬编码dir,因为我的 Jetty 安装在 Eclipse 外部,并且执行
解析为 .metadata 下的 jetty home。Had similar problem running Jetty from Eclipse via WST plugin. Here is how I solved it. Under workspace's .metadata directory found application's context:
[workspace's .metadata]/.plugins/org.eclipse.wst.server.core/[configuration id like 'tmp1']/contexts/[app name].xml .
Edited it to include the following under Configure tag:
<Set name="extraClasspath">[jetty install dir]/lib/jetty-websocket-8.1.2.v20120308.jar;[jetty install dir]/lib/jetty-util-8.1.2.v20120308.jar</Set>
Had to hardcode the Jetty install dir, since my Jetty is installed outside of Eclipse and doing the
<SystemProperty name="jetty.home" default="."/>
resolves to the jetty home under .metadata.