Maven dependencies Jersey selected at runtime

I have a Java Servlet project with Maven and Tomcat that contains the following two dependencies (among many others):

<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-server</artifactId>
    <version>2.25.1</version>
</dependency>
<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-serviceruntime</artifactId>
    <version>0.6.0</version>
</dependency>

      

jersey-server

includes javax.ws.rs-api:2.0.1

, but azure-serviceruntime

includes jersey-core:1.13

that contain the class Application

in the package javax.ws.rs.core

.

Searching for a type Application

in Eclipse reveals the following (for clarification): Two classes of applications

The problem is that the wrong class is being used at runtime Application

, which results in the following error when starting Tomcat:

java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;

      

For each servlet.

I tried to exclude jersey-core

from azure-serviceruntime

, but then the servlets don't load at all. I also tried adding javax.ws.rs-api

as a direct dependency, but that didn't work either. The most inexplicable part is that it works on Windows, but not Linux ... I also tried to move maven-tinged classes / packages, but without any success.

How can I tell Java to use the latter class Application

?

+3


source to share


2 answers


Finally I started working. I looked further to see that it works on Windows and not Linux, the difference is that on Windows I use OracleJDK and Linux in openJDK.



So I used OracleJDK for my project on Linux and now it works.

+1


source


I think it's best to use dependency exclusion to exclude jersey-core: 1.13 from azure-serviceruntime dependency:



<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-server</artifactId>
    <version>2.25.1</version>
</dependency>
<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-serviceruntime</artifactId>
    <version>0.6.0</version>
      <exclusions>
        <exclusion>
          <groupId>org.glassfish.jersey.core</groupId>
          <artifactId>jersey-core</artifactId>
        </exclusion>
      </exclusions>
</dependency>

      

0


source







All Articles