Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
736 views
in Technique[技术] by (71.8m points)

maven - NoSuchMethodError: org.eclipse.jetty.websocket.server.WebSocketServerFactory.<init>(Ljavax/servlet/ServletContext;)V

I have this exception when launching my application via eclipse plugin: "Run as" > "GWT Development Mode with jetty"

Environment:
- GWT SDK 2.8
- spring-boot 1.5.2.RELEASE
- jetty 9.4.2
- GWT Eclipse Plugin 3.0.0

Context: migrate a GWT 2.6 application to GWT 2.8 and using spring-boot
application pom generated with GWT webAppCreator

Here is the stack trace:

**Exception in thread "main" java.lang.NoSuchMethodError: 
org.eclipse.jetty.websocket.server.WebSocketServerFactory.<init>(Ljavax/servlet/ServletContext;)V**
at org.eclipse.jetty.websocket.server.NativeWebSocketConfiguration.<init>(NativeWebSocketConfiguration.java:53)
at org.eclipse.jetty.websocket.server.NativeWebSocketServletContainerInitializer.getDefaultFrom(NativeWebSocketServletContainerInitializer.java:36)
at org.eclipse.jetty.websocket.server.NativeWebSocketServletContainerInitializer.onStartup(NativeWebSocketServletContainerInitializer.java:46)
at org.eclipse.jetty.plus.annotation.ContainerInitializer.callStartup(ContainerInitializer.java:140)
at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart(ServletContainerInitializersStarter.java:63)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:329)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1480)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1442)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:799)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:540)
at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:550)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
at org.eclipse.jetty.server.Server.start(Server.java:452)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart(Server.java:419)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:759)
at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:634)
at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:923)
at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:706)
at com.google.gwt.dev.DevMode.main(DevMode.java:430)

Why my application fails to start?
Here is my pom and dependency tree . Thank you for your help

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <!-- POM file generated with GWT webAppCreator -->
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.mycompany.fonems.webapp</groupId>
 <artifactId>Fonemswebapp</artifactId>
 <packaging>war</packaging>
 <version>1.0-SNAPSHOT</version>
 <name>com.mycompany.fonems.webapp.Fonemswebapp</name>
  <parent> <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
  </parent>
 <properties>
   <!-- Setting maven.compiler.source to something different to 1.8
       needs that you configure the sourceLevel in gwt-maven-plugin since
       GWT compiler 2.8 requires 1.8 (see gwt-maven-plugin block below) -->
   <maven.compiler.source>1.8</maven.compiler.source>
   <maven.compiler.target>1.8</maven.compiler.target>
   <!-- Don't let your Mac use a crazy non-standard encoding -->
   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <smartgwt.version>3.1</smartgwt.version>
 </properties>
 <dependencyManagement>
   <dependencies>
    <!-- ensure all GWT deps use the same version (unless overridden) -->
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt</artifactId>
      <version>2.8.0</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
   </dependencies>
 </dependencyManagement>
 <dependencies>
    <dependency>
        <groupId>com.mycompany.fonems</groupId>
        <artifactId>fonems-fwk-server-common</artifactId>
        <version>0.0.104-SNAPSHOT</version>
        <exclusions>
            <exclusion>
                <artifactId>xercesImpl</artifactId>
                <groupId>xerces</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.mycompany.fonems</groupId>
        <artifactId>fonems-refonte-dao</artifactId>
        <version>0.0.104-SNAPSHOT</version>
        <exclusions>
            <exclusion>
                <artifactId>javax.el-api</artifactId>
                <groupId>javax.el</groupId>
            </exclusion>
            <exclusion>
                <artifactId>xercesImpl</artifactId>
                <groupId>xerces</groupId>
            </exclusion>
        </exclusions>
    </dependency>
   <dependency>
    <groupId>com.google.gwt</groupId>
    <artifactId>gwt-servlet</artifactId>
    <scope>runtime</scope>
   </dependency>
   <dependency>
    <groupId>com.google.gwt</groupId>
    <artifactId>gwt-user</artifactId>
    <scope>provided</scope>
   </dependency>
   <dependency>
    <groupId>com.google.gwt</groupId>
    <artifactId>gwt-dev</artifactId>
    <scope>provided</scope>
    <exclusions>
        <exclusion>
            <artifactId>xercesImpl</artifactId>
            <groupId>xerces</groupId>
        </exclusion>
    </exclusions>
   </dependency>
    <dependency>
        <groupId>com.smartgwt</groupId>
        <artifactId>smartgwt</artifactId>
        <version>${smartgwt.version}</version>
    </dependency>
        <dependency>
            <groupId>com.smartgwt</groupId>
            <artifactId>smartgwt-skins</artifactId>
            <version>${smartgwt.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mycompany.drh</groupId>
            <artifactId>newncauth</artifactId>
            <version>${mycompany.drh.version}</version>
        </dependency>
        <dependency>
            <groupId>mycompany.drh</groupId>
            <artifactId>mycompany.droits-habilitations.rmi</artifactId>
            <version>${mycompany.drh.rmi.version}</version>
        </dependency>
   <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <scope>test</scope>
   </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>compile</scope>
        </dependency>
 </dependencies>
 <build>
   <!-- Output classes directly into the webapp, so that IDEs and "mvn process-classes" update them in DevMode -->
   <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
   <plugins>
    <!-- GWT Maven Plugin-->
    <plugin>
      <groupId>net.ltgt.gwt.maven</groupId>
      <artifactId>gwt-maven-plugin</artifactId>
      <version>1.0-rc-6</version>
      <executions>
        <execution>
         <goals>
           <goal>import-sources</goal>
           <goal>compile</goal>
           <goal>import-test-sources</goal>
           <goal>test</goal>
         </goals>
        </execution>
      </executions>
      <configuration>
        <moduleName>com.mycompany.fonems.webapp.Fonemswebapp</moduleName>
        <moduleShortName>Fonemswebapp</moduleShortName>
        <failOnError>true</failOnError>
        <!-- GWT compiler 2.8 requires 1.8, hence define sourceLevel here if you use
            a different source language for java compilation -->
        <sourceLevel>1.8</sourceLevel>
        <!-- Compiler configuration -->
        <compilerArgs>
         <!-- Ask GWT to create the Story of Your Compile (SOYC) (gwt:compile) -->
         <arg>-compileReport</arg>
         <arg>-XcompilerMetrics</arg>
        </compilerArgs>
        <!-- DevMode configuration -->
        <warDir>${project.build.directory}/${project.build.finalName}</warDir>
        <classpathScope>compile+runtime</classpathScope>
        <!-- URL(s) that should be opened by DevMode (gwt:devmode). -->
        <startupUrls>
         <startupUrl>Fonemswebapp.html</startupUrl>
        </startupUrls>

<!--          <webappDirectory>${outputFolder}</webappDirectory> -->
      </configuration>

    </plugin>

    <!-- Skip normal test execution, we use gwt:test instead -->
    <plugin>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.17</version>
      <configuration>
        <skip>true</skip>
      </configuration>
    </plugin>
   </plugins>
 </build>
</project>

dependency tree:

------------------------------------------------------------------------
Building com.mycompany.fonems.webapp.Fonemswebapp 1.0-SNAPSHOT
------------------------------------------------------------------------

--- maven-dependency-plugin:2.10:tree (default-cli) @ Fonemswebapp ---
com.mycompany.fonems.webapp:Fonemswebapp:war:1.0-SNAPSHOT
+- com.mycompany.fonems:fonems-fwk-server-common:jar:0.0.104-SNAPSHOT:compile
|  +- commons-configuration:commons-configuration:jar:1.9:compile
|  |  - commons-logging:commons-log

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You have a mixture of Jetty versions on the class path: 9.4.2.v20170220 and 9.2.14.v20151106. The former is what Spring Boot 1.5.2 uses by default. I would guess that latter is from the import of com.google.gwt:gwt.

You could override the jetty.version property that Spring Boot uses to set its value to 9.2.14.v20151106, thereby using 9.2.14 everywhere. Alternatively, you could declare your own dependency management for the modules that are currently using 9.2.14 to upgrade them to 9.4.2.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...