user2818032
user2818032

Reputation: 101

spring cloud netflix jersey version conflict

Hello I have a Spring boot application that is using

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jersey</artifactId>
    </dependency>

This is dependent on Jersey version 2.7.

When trying to use

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>

That internally uses Jersey version 1.1, the application fails given the two different versions of the same library.

Any advice in how to fix this issue, I have tried to use only the version 2.7 but they seems to be not compatible each-other

Thanks

java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map; at org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:303) at org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:284) at org.glassfish.jersey.servlet.WebComponent.(WebComponent.java:311) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:168) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117) at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:220) at io.undertow.servlet.core.ManagedServlet.getServlet(ManagedServlet.java:163) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:84) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:82)

Upvotes: 5

Views: 2466

Answers (4)

Victor Grazi
Victor Grazi

Reputation: 16510

I was having the same problem, until I moved spring-boot-starter-jersey to the top of the dependencies. That seems to cure it completely.

Upvotes: 0

user2818032
user2818032

Reputation: 101

I manage to solve my issue, this is not the best but it works, I have made a strip-out version of the library, replacing jersey client with a cxf library, and it works perfectly.

https://github.com/MicroIdeas/service-registry/tree/master/src/main/java/co/microideas/framework

Upvotes: 0

Thor&#39;s beard
Thor&#39;s beard

Reputation: 31

I have gotten the setup with Jersey 2 and Eureka client all through spring cloud to work by specifying the following:

    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
            <excludes>
                <exclude>
                    <groupId>javax.ws.rs</groupId>
                    <artifactId>jsr311-api</artifactId>
                </exclude>
            </excludes>
        </configuration>
    </plugin>

The only problem though is that the tests are not running yet. But we are still trying to find a full solution to the problem.

Upvotes: 3

PaulNUK
PaulNUK

Reputation: 5229

Hmm, that's not good. Jersey 1 and 2 are significantly different. I think the only option you have is to remove spring-boot-starter-jersey and code to Jersey 1.1.

It might be worth looking at the spring-boot-starter-jersey code to see what it gives you when it autoconfigures stuff, which might help you in your coding.

It's very unfortunate, as Spring boot is supposed to give you a curated, compatible set of dependencies, but it looks like spring-cloud-starter-eureka hasn't been folded into Spring boot, so you are stuck with using an old API.

Upvotes: 0

Related Questions