Eureka and Jersey 2.x
Asked Answered
D

2

4

I am using Spring Boot and looking for a discovery server. I see that "spring-cloud-starter-netflix-eureka-server" has a dependency on Jersey 1.x which is not an option to use in my environment. There are a couple of threads talking about adding compatibility with Jersey 2.x and some others talking about removing Jersey all together.

However I don't see any links to documentation/code related to either of these options and how to use them. Can someone please point me to the options I have here?

Here are the links I was able to gather on this so far:
https://github.com/Netflix/eureka/issues/600
https://github.com/Netflix/eureka/tree/contrib/jersey2-compatibility/eureka-core-jersey2

Donate answered 17/5, 2018 at 21:27 Comment(0)
R
2

Below dependencies worked for me. See my pom

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.3.RELEASE</version>
</parent>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    <version>2.0.0.RELEASE</version>
    <exclusions>
        <exclusion>
          <groupId>javax.ws.rs</groupId>
          <artifactId>jsr311-api</artifactId>
       </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
Rahman answered 5/7, 2018 at 11:30 Comment(0)
N
1

Spring Boot Jersey starter brings in Jersey 2.x while Spring Cloud Eureka starter brings in eureka client dependency which transitively includes Jersey 1.x.

Basically Spring Boot Jersey starter and Spring Cloud Eureka starter won't play along until eureka client is upgraded to use Jersey 2.x.

Most likely you are getting error(s) like java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;

Your options would be:

Nacelle answered 17/5, 2018 at 21:54 Comment(2)
Thanks for the response. Unfortunately Jersey 1.x is not supported in the application container we are allowed to run our apps on. So option 2 is ruled out and neither are we using JAX-RS/Jersey spec/implementations. I was looking for an out of the box solution for a discovery server, but based on your comments, is building one the only option?Donate
Take a look at Spring Cloud Consul - cloud.spring.io/spring-cloud-consul. It could be used for service discovery and distributed configurationNacelle

© 2022 - 2024 — McMap. All rights reserved.