3
votes

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!

1
I would suggest to remove that embedded container or not to use Spring Boot. You have competing containers. Also your container doesn't follow the principle that Spring Boot expects so it probably won't even work (reliably).M. Deinum
@M.Deinum Thanks for responding. The app is a microservice actually. I am developing the microservice using using Spring Boot. So can't remove Spring Boot.deepankardixit90
Judging from your question you are moving to Spring Boot so why wouldn't you be able to remove it.M. Deinum
Remove embedded container? I removed the default tomcat container from Spring Boot. I left the Jetty dependency (org.eclipse.jetty) as it is as I wanted to use the same. If I remove this as well I will need to use embedded Jetty from Spring Boot and make code change in classes depending on Jetty version 8.2 as there are changes between Jetty 8.2 and 9.4 which Spring Boot 2.1.1 will use.deepankardixit90
Spring Boot 2.1 doesn't work with Jetty 8....M. Deinum

1 Answers

2
votes

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.