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.
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:
<Set name="extraClasspath"><SystemProperty name="jetty.home" default="."/>/lib/jetty-websocket-<version>.jar</Set>
I experienced the same using jetty-maven-plugin and version 8.0.3.v20111011
. However the solution was simple. Just include the jetty-websocket
as a compiled scope dependency (i.e. don't declared scope).
Relevant sections of pom.xml
:
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jetty.version>8.0.3.v20111011</jetty.version>
</properties>
...
<build>
<plugins>
...
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-websocket</artifactId>
<version>${jetty.version}</version>
</dependency>
...
</dependencies>
copy %JETTY_ROOT%\lib\jetty-websocket-<version>.jar %SERVLET_ROOT%\WEB-INF\lib
Seemed to work great for me!
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.