NoSuchMethodError on startup in Java Jersey app

jersey 2 example
java lang nosuchmethoderror javax ws rs core application getproperties l
java lang nosuchmethoderror javax/ws/rs core httpheaders getheaderstring
rest api example java
httpauthenticationfeature maven
restful web services example in java using eclipse step by step
org glassfish jersey commonproperties
jersey-core maven

I've been getting a very strange error when trying to start a Jersey app on Tomcat. The same code works on other computers. I tried reinstalling tomcat, all my maven dependencies, even Eclipse and Java itself, no luck. It seems like a bad Jersey version is being loaded, I think?

Any pointers in the right direction will be appreciated.

Here's the effective pom: http://pastebin.com/NacsWTjz

And the actual pom: http://pastebin.com/H6sHe4ce

2015-02-13 13:43:40,870 [localhost-startStop-1] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/middleware-server] - StandardWrapper.Throwable
java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:304)
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285)
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4901)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5188)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Note: Please see above comments for further discussion and tips.

This error usual means that you have a both a JAX-RS 1 and JAX-RS 2 jar on the classpath. Jersey 2 uses JAX-RS 2 (javax.ws.rs-api-2.0.1.jar), but if you have the jsr311-api.jar also, which is JAX-RS 1, there is a javax.ws.rs.core.Application in each jar. But the jsr311-api Application doesn't have the method getProperties() (hence NoSuchMethodError).

I've come to the conclusion that all you need to do is add the above exclusion to the swagger dependency. The Jackson 2.0 provider (which depends on JAX-RS 1) seems to be overridden by a 2.4.1 provider (which uses the new version). So we don't need to add it ourselves. When it's overridden, it seems to leave behind the jsr311-api.jar. So if we exclude it, no one can attempt to use it, which looks to be the current problem

<dependency>
    <groupId>com.wordnik</groupId>
    <artifactId>swagger-core_2.10</artifactId>
    <version>1.3.11</version>
    <exclusions>
        <exclusion>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Jersey 2 hello world example - Jersey 2 tutorial, In this jersey 2 example, I will go through migration/configuration steps in First change, you will need to make in your jersey 1.x application will be in pom.xml. .com/questions/28509370/nosuchmethoderror-on-startup-in-java-jersey-app. I recently tried to move my Jersey application from running on Glassfish 4.1 to run on Tomcat 8. The application is successfully deployed on tomcat: 03-Aug-2015 18:42:07.982 INFO [localhost-start

We are using jersey-json 1.9 which has a dependency on jersey-core which also happen to have a javax.ws.rs.core.Application class.

So our fix is to exclude the jersey-core from jersey-json:

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>1.9</version>
        <exclusions>
            <exclusion>
                <groupId>com.sun.jersey</groupId>
                <artifactId>jersey-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

java.lang.NoSuchMethodError: javax.ws.rs.core.Application , 8.5 and giving java.lang.NoSuchMethodError: javax/ws/rs/core/Application. RestfulResourceLoader JAX-RS application class that is named in the javax.ws.​rs.Application init-param SpringApplication - Application startup failed java.​lang. NoSuchMethodError on startup in Java Jersey app (3) . We are using jersey-json 1.9 which has a dependency on jersey-core which also happen to have a javax.ws.rs.core

the problem is related about "com.sun.jersey:jersey-core:jar:1.18.3" (or any 1.* version) because old versions of Jersey didn't have that "public Map getProperties()" method.

And one of your dependencies use Jersey version 1 (you can check that in running mvn dependency:tree and search all jersey-core version used)

Me I have resolved the problem deleting all com.sun.jersey dependancies (old api) and using the new one org.glassfish.jersey API

https://mvnrepository.com/artifact/org.glassfish.jersey.core

java, I am not sure if this can be the cause but I checked under package and have v1.9 of both jersey-core & jersey-client jars. Thanks. Y una de sus dependencias Jersey versión 1 (usted puede verificar que en la ejecución de mvn dependencia:árbol y buscar en todos los jersey-core versión usa) Me ha resuelto el problema de la eliminación de todas las com.sol.jersey de dependencia (edad api) y con la nueva org.glassfish.jersey API

You can change the tomcat version to 7 then it will run no need to change pom.xml

Jersey rest lib from a war is clashing in WAS 8.5 and giving java , As mentioned in the JBoss AS 7 documentation, the version of the JAX-RS specification used is 1.1.. Therefore, in order to use Jsersey 2.X, which provides support for JAX-RS APIs and serves both JAX-RS 1.x and JAX-RS 2.x reference implementations, you need to exclude the conflicts with RESTEasy by adding the following to your WEB-INF/jboss-deployment-structure.xml:

WebAPI JAR Conflict - Implementers, Ok looked at your issue. The External Glassfish v 3.1.2.2 that you are using is JAVA-EE 6 compatible. And the one through which you are running your app in eclipse is JAVA-EE 7 compatible. Have a look at both the java docs: Application class Java Doc for EE6 Application class

org.glassfish.jersey.server.ContainerException: java.lang , The External Glassfish v 3.1.2.2 that you are using is JAVA-EE 6 compatible. And the one through which you are running your app in eclipse is JAVA-EE 7 compatible. Have a look at both the java docs: Application class Java Doc for EE6 Application class Java Doc for EE7 You will see that the getProperties method got introduced in JAVA-EE 7.

java.lang.NoSuchMethodError: javax.ws.rs.core.Application , Select jersey quick start version. Fill artifact Id and Group Id. Fill Artifact id and Group Id. Click ‘OK’ to create this project. Project will be created in workspace. Generated Files. Let’s look at generated files. Folder Structure Default Generated Files web.xml <?xml version="1.0" encoding="UTF-8"?> <!--

Comments
  • Looks like you have incompatible jars in your classpath
  • I hope you are not in a jar hell.
  • I've been in jar hell for the last 3 days.. didn't get any work done because of that.
  • You have a version mismatch. Can you post your pom?
  • Here's the effective pom, thank you so much: pastebin.com/NacsWTjz
  • In my case the jsr311-api.jar came with spring-cloud-starter-eureka, so excluding it there (like @peeskillet showed) solved my problem.
  • The version I am using is a little different: jaxrs-ri-2.28.zip. I am able to create a war file with maven.