Jetty: NoClassDefFoundError

10.2k views Asked by At

I have a pom where I configured jetty plugin in following way:

<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>9.4.0.v20161208</version>
     <configuration>
        <skip>${skipTests}</skip>
        <scanIntervalSeconds>10</scanIntervalSeconds>
        <stopPort>8005</stopPort>
        <stopKey>STOP</stopKey>
        <webAppSourceDirectory>${basedir}/target/${project.artifactId}-test</webAppSourceDirectory>
        <httpConnector>
          <port>45098</port>
          <idleTimeout>60000</idleTimeout>
        </httpConnector>
        <daemon>true</daemon>
      </configuration>
      <executions>
         <execution>
            <id>start-jetty</id>
            <phase>pre-integration-test</phase>
               <goals>
                  <goal>start</goal>
               </goals>
               <configuration>
                  <scanIntervalSeconds>0</scanIntervalSeconds>
               </configuration>
          </execution>
          <execution>
             <id>stop-jetty</id>
             <phase>post-integration-test</phase>
             <goals>
                <goal>stop</goal>
             </goals>
          </execution>
        </executions>
      </plugin>

But when the jetty stopping I get exception:

Exception in thread "Thread-4" java.lang.NoClassDefFoundError: org/eclipse/jetty/io/ManagedSelector$CloseEndPoints
at org.eclipse.jetty.io.ManagedSelector.doStop(ManagedSelector.java:135)
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:142)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:160)
at org.eclipse.jetty.io.SelectorManager.doStop(SelectorManager.java:257)
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:142)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:160)
at org.eclipse.jetty.client.AbstractHttpClientTransport.doStop(AbstractHttpClientTransport.java:87)
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:142)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:160)
at org.eclipse.jetty.client.HttpClient.doStop(HttpClient.java:255)
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:142)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:160)
at org.eclipse.jetty.websocket.client.WebSocketClient.doStop(WebSocketClient.java:379)
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:142)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:160)
at org.eclipse.jetty.websocket.jsr356.ClientContainer.doStop(ClientContainer.java:214)
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
at org.eclipse.jetty.util.thread.ShutdownThread.run(ShutdownThread.java:138)

I tried to add dependency section with jetty server lib to plugin, but it didn't have success.

4

There are 4 answers

0
Mickael On

I think you need to add a dependency to your plugin. ManagedSelector is available in the following dependency :

<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-io</artifactId>
    <version>9.4.0.v20161208</version>
</dependency>

You can update your pom.xml like this :

<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>9.4.0.v20161208</version>
  <dependencies>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-io</artifactId>
      <version>9.4.0.v20161208</version>
    </dependency>
  </dependencies>
  <configuration>
    <skip>${skipTests}</skip>
    <scanIntervalSeconds>10</scanIntervalSeconds>
    <stopPort>8005</stopPort>
    <stopKey>STOP</stopKey>
    <webAppSourceDirectory>${basedir}/target/${project.artifactId}-test</webAppSourceDirectory>
    <httpConnector>
      <port>45098</port>
      <idleTimeout>60000</idleTimeout>
    </httpConnector>
    <daemon>true</daemon>
  </configuration>
  <executions>
    <execution>
      <id>start-jetty</id>
      <phase>pre-integration-test</phase>
      <goals>
        <goal>start</goal>
      </goals>
      <configuration>
        <scanIntervalSeconds>0</scanIntervalSeconds>
      </configuration>
    </execution>
    <execution>
      <id>stop-jetty</id>
      <phase>post-integration-test</phase>
      <goals>
        <goal>stop</goal>
      </goals>
    </execution>
  </executions>
</plugin>
0
Hasitha Nanayakkara On

Check your port whether something is running on that port, Jetty default port is 8080.

0
Nupur On

I had the same problem, for which

  1. I included the jetty plugin in my pom.xml file and
  2. Stopped the ruuning jetty,
  3. cleared the console and
  4. updated the maven project, then it started running.

pom.xml --> plugin added

`<plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.4.3.v20170317</version>
    <configuration>
      <!-- http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html -->
      <scanIntervalSeconds>3</scanIntervalSeconds>
      <!--  By Default, jetty start on port 8080
      <httpConnector>
          <port>9090</port>
      </httpConnector>
      -->
    </configuration>
  </plugin>`

0
Yu Jiaao On

I have the some problem too, when I run the command

 mvn integration-test

the output is

Downloading: http://myserver.com/repo/org/eclipse/jetty/jetty-maven-plugin/9.4.3.v20170317/jetty-maven-plugin-9.4.3.v20170317.pom
Downloaded: http://myserver.com/repo/org/eclipse/jetty/jetty-maven-plugin/9.4.3.v20170317/jetty-maven-plugin-9.4.3.v20170317.pom (6 KB at 3.4 KB/sec)
Downloading: http://myserver.com/repo/org/eclipse/jetty/jetty-maven-plugin/9.4.3.v20170317/jetty-maven-plugin-9.4.3.v20170317.jar
Downloaded: http://myserver.com/repo/org/eclipse/jetty/jetty-maven-plugin/9.4.3.v20170317/jetty-maven-plugin-9.4.3.v20170317.jar (101 KB at 35.0 KB/sec)
Downloading: http://myserver.com/repo/org/eclipse/jetty/jetty-io/9.2.20.v20161216/jetty-io-9.2.20.v20161216.pom
Downloaded: http://myserver.com/repo/org/eclipse/jetty/jetty-io/9.2.20.v20161216/jetty-io-9.2.20.v20161216.pom (3 KB at 2.3 KB/sec)
Downloading: http://myserver.com/repo/org/eclipse/jetty/jetty-io/9.4.3.v20170317/jetty-io-9.4.3.v20170317.pom
Downloaded: http://myserver.com/repo/org/eclipse/jetty/jetty-io/9.4.3.v20170317/jetty-io-9.4.3.v20170317.pom (2 KB at 1.3 KB/sec)
Downloading: http://myserver.com/repo/org/eclipse/jetty/jetty-io/9.4.3.v20170317/jetty-io-9.4.3.v20170317.jar
Downloaded: http://myserver.com/repo/org/eclipse/jetty/jetty-io/9.4.3.v20170317/jetty-io-9.4.3.v20170317.jar (128 KB at 43.2 KB/sec)

the strange things is that some thing depends on jetty-io 9.2.20 while in my pom.xml there are nothing like this.

then I downgrade jetty-maven-plugin from 9.4.3.v20170317 to 9.2.20.v20161216, the problem vanished.

My pom.xml:

<properties>
        <jetty.version>9.2.20.v20161216</jetty.version>
</properties>

......

<plugin>
            <!-- if jetty 7,8 use groupId org.mortbay.jetty, if jetty 9 use org.eclipse.jetty -->
            <!--
            <groupId>org.mortbay.jetty</groupId>
-->
            <groupId>org.eclipse.jetty</groupId> 
            <artifactId>jetty-maven-plugin</artifactId>
            <version>${jetty.version}</version>
            <configuration>
                <jvmArgs>-Xmx2048m -Xms1536m -XX:PermSize=256m -XX:MaxPermSize=512m</jvmArgs>
                <webAppSourceDirectory>${project.basedir}/WebContent</webAppSourceDirectory>
                <stopKey>foo</stopKey>
                <stopPort>9999</stopPort>
                <stopWait>5</stopWait>
                <webAppConfig>
                    <contextPath>/</contextPath>
                </webAppConfig>
                <scanIntervalSeconds>1000</scanIntervalSeconds>
            </configuration>

            <executions>
                <execution>
                    <id>start-jetty</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>start</goal>
                    </goals>
                    <configuration>
                        <scanIntervalSeconds>0</scanIntervalSeconds>
                    </configuration>
                </execution>
                <execution>
                    <id>stop-jetty</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>

            <dependencies>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-all</artifactId>
                    <version>2.4.10</version> 
                </dependency>
                <dependency>
                  <groupId>org.eclipse.jetty</groupId>
                  <artifactId>jetty-io</artifactId>
                  <version>${jetty.version}</version>
                </dependency>
            </dependencies>

        </plugin>