Search code examples
javaspringspring-bootnetflix-eurekaspring-io

The Spring boot application(eureka client) is throwing ClassNotFoundException: javax.ws.rs.core.Response$StatusType


I am trying register my Spring boot application to a eureka server. The application get's start but at runtime I am getting

"java.lang.NoClassDefFoundError: javax/ws/rs/core/Response$StatusType
    at com.sun.jersey.api.client.ClientResponse.<init>(ClientResponse.java:381) ~[jersey-client-1.19.1.jar:1.19.1]
    at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:176) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
    at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[jersey-client-1.19.1.jar:1.19.1]
    at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.4.12.jar:1.4.12]
    at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.1.jar:1.19.1]
    at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.1.jar:1.19.1]
    at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.19.1.jar:1.19.1]

Build.gradle:

buildscript {
repositories {
     mavenCentral()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootGradleVersion}")
}}

dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-config'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-eureka'

}

Any help is highly appreciated.

Thanks In Advance!!


Solution

  • You're probably missing all the necessary WS dependencies. As you're using Spring Boot, this will be the best way to get them:

    compile("org.springframework.boot:spring-boot-starter-web-services")
    // or
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web-services'
    

    Depending on your version of Spring Boot, it might be called spring-boot-starter-ws instead.

    P.S. I'm not sure why you're mixing dependency styles. Just pick one and use it everywhere.