Jetty 8 web sockets

前端 未结 4 2076
灰色年华
灰色年华 2021-01-06 12:59

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:

         


        
相关标签:
4条回答
  • 2021-01-06 13:44
    copy %JETTY_ROOT%\lib\jetty-websocket-<version>.jar %SERVLET_ROOT%\WEB-INF\lib
    

    Seemed to work great for me!

    0 讨论(0)
  • 2021-01-06 13:46

    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.

    0 讨论(0)
  • 2021-01-06 13:49

    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>
    
    0 讨论(0)
  • 2021-01-06 13:52

    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>
    
    0 讨论(0)
提交回复
热议问题