1

I'm trying to create a simple RESTful web application. For that I've created (Eclipse) a new Maven Project using jersey-quickstart-webapp archetype. Upon deployment i receive the following error:

ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/test]] (MSC service thread 1-4) StandardWrapper.Throwable: java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;

My Maven dependencies, pPOM and web.xml are below:

dependencies

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>test</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>test</name>

<build>
    <finalName>test</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <inherited>true</inherited>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey</groupId>
            <artifactId>jersey-bom</artifactId>
            <version>${jersey.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet-core</artifactId>
        <!-- use the following artifactId if you don't need servlet 2.x compatibility -->
        <!-- artifactId>jersey-container-servlet</artifactId -->
    </dependency>
    <!-- uncomment this to get JSON support
    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-moxy</artifactId>
    </dependency>
    -->
</dependencies>
<properties>
    <jersey.version>2.23.2</jersey.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<?xml version="1.0" encoding="UTF-8"?>
<!-- This web.xml file is not required when using Servlet 3.0 container,
     see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html -->
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.    com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <servlet>
        <servlet-name>Jersey Web Application</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>com.example.test</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey Web Application</servlet-name>
        <url-pattern>/webapi/*</url-pattern>
    </servlet-mapping>
    <context-param>
            <param-name>resteasy.scan</param-name>
            <param-value>false</param-value>
        </context-param>
        <context-param>
            <param-name>resteasy.scan.providers</param-name>
            <param-value>false</param-value>
        </context-param>
        <context-param>
            <param-name>resteasy.scan.resources</param-name>
            <param-value>false</param-value>
        </context-param>
</web-app>

The target is a remote JBoss 7.0.2 server.

Other than slightly modifying the web.xml I haven't done any other modifications to the default project. I've searched through similar threads but none seemed to help (I'm probably missing some detail I don't currently see).

J_S
  • 2,985
  • 3
  • 15
  • 38
  • 2
    In these cases, it is usually a JAR conflict. From eclipse search for the type (Ctrl Shift T) `javax.ws.rs.core.Application`. If you get more than one copy of different versions which are linked to the project, you might have to remove other versions. Also, try clearing your local Maven repo and running mvn clean package again. – Vasan Aug 30 '16 at 13:45
  • As Vasan pointed out atleast 2 different versions of the same class are on the classpath – vinay Aug 30 '16 at 13:50
  • you may have the same problem with the one mentioned in the answer here:[NoSuchMethodError on startup in Java Jersey app](http://stackoverflow.com/questions/28509370/nosuchmethoderror-on-startup-in-java-jersey-app?answertab=active#tab-top), do a `mvn dependency:tree` to check if there is a dependency conflict – qingl97 Aug 30 '16 at 13:52
  • @Vasan I did as you've suggested, only one copy is shown and it points to JAX-RS 2.0.1 – J_S Aug 31 '16 at 07:21
  • @qingl97 I've checked for dependency conflicts in the dependency hierarchy and the only conflicts that do show up mention the same version that is already used. My dependency hierarchy is [here](http://imgur.com/a/EK10F) – J_S Aug 31 '16 at 07:24
  • I took a different approach. The issue I've had seems to be related to RESTEasy which comes bundled with JBoss which might've caused issues with Jersey from the project. As this is just a test project and I have full control of both project and the server I decided to do things properly from scratch. Upgraded to WildFly 10.1.0 and created a new project based on RESTEasy. Ran the project flawlessly. I'm going to leave this as unanswered, as this is not a solution to the original problem, but rather a different approach. – J_S Sep 02 '16 at 12:24

0 Answers0