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

前端 未结 5 962
太阳男子
太阳男子 2020-12-10 05:49

I am having an issue running a servlet in jetty on Ubuntu 13.04. The server is installed using apt-get and started using sudo service jetty start.

相关标签:
5条回答
  • 2020-12-10 05:56

    In deployment environment, just make sure your server classpath has included the Spring jar library (e.g spring-2.5.6.jar).

    For Spring3, ContextLoaderListener is moved to spring-web.jar, you can get the library from Maven central repository.

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>3.0.5.RELEASE</version>
    </dependency>
    

    http://www.mkyong.com/spring/spring-error-classnotfoundexception-org-springframework-web-context-contextloaderlistener/

    0 讨论(0)
  • 2020-12-10 06:01

    Put the following into your webapps/YOURWAR.xml, within the <Configure class="org.eclipse.jetty.webapp.WebAppContext"> (the - in front of org.eclipse.jetty.util. is important):

    <Call name="prependServerClass">
      <Arg>-org.eclipse.jetty.util.</Arg>
    </Call>
    

    You need to prepend it, because the order is important and the last one which is added by default is org.eclipse.jetty. as documented on eclipse.org. So calling addServerClass would be a no-op, as org.eclipse.jetty.util. is already be excluded by org.eclipse.jetty..

    0 讨论(0)
  • 2020-12-10 06:03

    Joakim Erdfelt pointed the cause, in case anyone needs a snip of pom code, put this in pom file:

    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-util</artifactId>
      <version>9.3.6.v20151106</version>
    </dependency>
    
    0 讨论(0)
  • 2020-12-10 06:10

    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.

    0 讨论(0)
  • 2020-12-10 06:20

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