Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot APPLICATION FAILED TO START as class org.eclipse.jetty.server.Server does not exist

I am migrating a web application to a Spring Boot application which fails to start and displays the following error message :

    An attempt was made to call the method org.eclipse.jetty.server.Server. 
     <init>(Lorg/eclipse/jetty/util/thread/ThreadPool;)V but it does not 
     exist. 
     Its class, org.eclipse.jetty.server.Server, is available from the 
     following locations:

    jar:file:/C:/Users/xyz/.m2/repository/org/eclipse/jetty/jetty- 
    server/8.2.0.v20160908/jetty-server- 
    8.2.0.v20160908.jar!/org/eclipse/jetty/server/Server.class

    It was loaded from the following location:

    file:/C:/Users/xyz/.m2/repository/org/eclipse/jetty/jetty- 
    server/8.2.0.v20160908/jetty-server-8.2.0.v20160908.jar


    Action:

    Correct the classpath of your application so that it contains a single, 
    compatible version of org.eclipse.jetty.server.Server

As there is just one location (C:/Users/xyz/.m2/repository/org/eclipse/jetty/jetty- server/8.2.0.v20160908/jetty-server-8.2.0.v20160908.jar) as pointed by Spring Boot, there should be no ambiguity. I have provided all the required maven dependencies with version 8.2.0.v20160908. I have excluded tomcat dependency (spring-boot-starter-tomcat) from spring-boot-starter-web as I need to work with jetty. But I have NOT included jetty spring boot starter dependency in spring-boot-starter-web as I already have embedded jetty dependencies with group id org.eclipse.jetty defined through which jetty dependencies (jetty-server, jetty-servlet, jetty-security, jetty-http, jetty-util, jetty-webapp, jetty-xml, jetty-io, jetty-deploy etc) are provided.

The Spring Boot version is v2.1.1.RELEASE.

The jetty server is defined as spring bean which is as follows

      <bean id="webServer" class="org.someorg.server.jetty.Server">
        <property name="threadPool">
            <bean class="org.eclipse.jetty.util.thread.QueuedThreadPool">
                <property name="minThreads" value="8" />
                <property name="maxThreads" value="32" />
            </bean>
        </property>
        <property name="connectors">
            <list>
                <bean class="org.someorg.server.jetty.XmlConnector">
                    <property name="port" value="34347" />
                </bean>
                <bean class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
                    <property name="port" value="34346" />
                    <property name="keystore" value="classpath:keystore" />
                    <property name="password" value="somepassword" />
                    <property name="keyPassword" value="somekeypassword" />
                    <property name="truststore" value="classpath:keystore" />
                    <property name="trustPassword" value="sometrustpassword" 
      />
                </bean>
                <bean 
      class="org.eclipse.jetty.server.nio.SelectChannelConnector">
                    <property name="port" value="34345" />
                </bean>
            </list>
        </property>
        <property name="handler">
            <bean class="org.eclipse.jetty.server.handler.HandlerCollection">
                <property name="handlers">
                    <list>
                        <ref bean="webContexts" />
                        <bean id="defaultHandler" 
       class="org.eclipse.jetty.server.handler.DefaultHandler" />
                    </list>
                </property>
            </bean>
        </property>
        <property name="beans">
            <list>
                <bean class="org.eclipse.jetty.deploy.WebAppDeployer">
                    <property name="contexts" ref="webContexts" />
                    <property name="webAppDir" value="webapps" />
                </bean>
            </list>
        </property>
        <property name="stopAtShutdown" value="false" />
     </bean>`

Class Server looks like the following :

public class Server extends org.eclipse.jetty.server.Server implements 
ApplicationListener<ApplicationContextEvent> {

 // code here

}

I am not sure here what Spring Boot is expecting here. I do not have any other jetty versions as I see in Maven Dependency Hierarchy. All maven dependencies are on classpath.

Any pointers ?

Thanks!

like image 825
raghav Avatar asked Oct 17 '25 09:10

raghav


1 Answers

You are using a version of jetty incompatible to the selected version of spring boot.

spring-boot-starter-web 2.1.1.RELEASE depends on spring-web 5.1.3.RELEASE which depends on jetty-server 9.4.14.v20181114.

You'll have to upgrade your jetty dependency.

like image 190
Selaron Avatar answered Oct 20 '25 00:10

Selaron