I\'m trying to create a Docker image from my Jersey web application running on a Tomcat server. I\'m developing on a Windows 7 machine.
I have deployed the web appli
Here is an indepth overview and a solution to all who encounter NoSuchMethodError especially in jersey context.
The problem is
java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
In Java NoSuchMethodError is thrown when the JVM cant find the method specified in the specified class. From https://docs.oracle.com/javase/9/docs/api/java/lang/NoSuchMethodError.html
Thrown if an application tries to call a specified method of a class (either static or instance), and that class no longer has a definition of that method.
In your case JVM is complaining that javax.ws.rs.core.Application
doesnot have getProperties()
method.
Jesey 2.x uses JEE 7. In JEE 7 version of javax.ws.rs.core.Application
has
getClasses()
getSingeltons()
getProperties()
methods defined. https://docs.oracle.com/javaee/7/api/javax/ws/rs/core/Application.htmlJesey 1.x uses JEE 6. In JEE 6 version of javax.ws.rs.core.Application
only has
getClasses()
getclass()
But getProperties()
is not defined. https://jersey.github.io/apidocs/1.19.1/jersey/javax/ws/rs/core/Application.html
Solution
You have jersey 2.x and 1.x versions defined in your pom.xml. Therefore there are both JEE6 and 7 versions of javax.ws.rs.core.Application
in your classpath and classloader loads JEE 6 version of appliction class which doesnot have getProperties()
defined but yor application wants to execute getProperties()
anyway. Hence the error.
Remove all jersey 1.x versions from your pom.xml and stick to jersey 2.x version. The classloader will take care of the rest.