ClassNotFoundException: org.eclipse.jetty.util.component.AbstractLifeCycle running inside jetty

Put the jetty-util-9.0.4.v20130625.jar in your webapp's WEB-INF/lib/

As you can see from the stacktrace, you are attempting to use a class found in jetty-util, from within a webapp.

at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:420)

This tells you that the webapp needs the class from jetty-util.

Because of webapp classloader isolation, and various rules within Jetty, the classes for org.eclipse.jetty.util.* are not provided by the server, and must be provided by the webapp's own WEB-INF/lib directory.


I got this when combining wiremock and DynamoDBLocal which both includes different versions of jetty. Excluding these dependencies in each of these and then explicitly having these in the pom with a specific version. However, seems org.eclipse.jetty.util.component.AbstractLifeCycle is only used in up to version 8.2.0.v20160908 (hence it does not solve it to have a newer version)

See example below:

<properties>
    <jetty.version>8.2.0.v20160908</jetty.version>
</properties>

    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>DynamoDBLocal</artifactId>
        <version>${dynamodb-local.version}</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
              <groupId>org.eclipse.jetty</groupId>
              <artifactId>jetty-util</artifactId>
            </exclusion>
           <exclusion>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-io</artifactId>
           </exclusion>
            <exclusion>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-security</artifactId>
           </exclusion>
           <exclusion>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-servlets</artifactId>
           </exclusion>
           <exclusion>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-webapp</artifactId>
           </exclusion>
           <exclusion>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-webapp</artifactId>
           </exclusion>
           <exclusion>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-xml</artifactId>
           </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.github.tomakehurst</groupId>
        <artifactId>wiremock</artifactId>
        <exclusions>
          <exclusion>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
          </exclusion>
           <exclusion>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-util</artifactId>
           </exclusion>
           <exclusion>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-io</artifactId>
           </exclusion>
            <exclusion>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-security</artifactId>
           </exclusion>
           <exclusion>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-servlets</artifactId>
           </exclusion>
           <exclusion>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-webapp</artifactId>
           </exclusion>
           <exclusion>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-webapp</artifactId>
           </exclusion>
           <exclusion>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-xml</artifactId>
           </exclusion>
       </exclusions> 
        <version>${wiremock.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-util</artifactId>
      <version>${jetty.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-io</artifactId>
      <version>${jetty.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-security</artifactId>
      <version>${jetty.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-servlets</artifactId>
      <version>${jetty.version}</version>
      <scope>test</scope>
    </dependency> 
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-webapp</artifactId>
      <version>${jetty.version}</version>
      <scope>test</scope>
    </dependency>       
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-xml</artifactId>
      <version>${jetty.version}</version>
      <scope>test</scope>
    </dependency>