Marcos J.C Kichel
Marcos J.C Kichel

Reputation: 7219

Error on JAX-RS webservice startup

I refactored an working JAX-RS, Jersey implementation, webservice in order to isolate it entities so them can be used as a library, I also changed the project and package name, now when I try to get tomcat up I got this java.lang.NoSuchMethodError error:

 org.glassfish.jersey.model.internal.RankedProvider.getContractTypes()Ljava/util/Set;
    at org.glassfish.jersey.server.ApplicationHandler.filterNameBound(ApplicationHandler.java:801)
    at org.glassfish.jersey.server.ApplicationHandler.getProcessingProviders(ApplicationHandler.java:702)
    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:484)
    at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:166)
    at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:327)

I have googled but cant find anything related to this specific error

Those are the dependencies of the entity project:

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.logtec</groupId>
<artifactId>zaprango-entity</artifactId>
<version>1.0</version>

<profiles>
    <profile>
        <id>default</id>

        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>

        <properties>
            <qbeasy.version>1.1</qbeasy.version>
            <maven-compiler.version>1.8</maven-compiler.version>
            <uk.co.jemos.podam.podam.version>4.7.3.RELEASE</uk.co.jemos.podam.podam.version>
        </properties>

        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.2</version>
                    <configuration>
                        <source>${maven-compiler.version}</source>
                        <target>${maven-compiler.version}</target>
                    </configuration>
                </plugin>
            </plugins>          
        </build>

        <dependencies>
            <!-- QBEasy -->
            <dependency>
                <groupId>br.com.boilerplatecorp</groupId>
                <artifactId>qbeasy</artifactId>
                <version>${qbeasy.version}</version>
            </dependency>

            <!-- PoDam -->
            <dependency>
                <groupId>uk.co.jemos.podam</groupId>
                <artifactId>podam</artifactId>
                <version>${uk.co.jemos.podam.podam.version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </profile>

    <profile>
        <id>tomcat</id>

        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>

        <properties>
            <jersey-servlet.version>2.16</jersey-servlet.version>
            <org.hibernate.version>4.3.6.Final</org.hibernate.version>
            <jackson.version>2.16</jackson.version>
        </properties>

        <dependencies>
            <!-- JPA/Hibernate Impl -->
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>${org.hibernate.version}</version>
            </dependency>

            <!-- Jackson -->
            <dependency>
                <groupId>org.glassfish.jersey.media</groupId>
                <artifactId>jersey-media-json-jackson</artifactId>
                <version>${jackson.version}</version>
                <exclusions>
                    <exclusion>
                        <artifactId>jackson-annotations</artifactId>
                        <groupId>com.fasterxml.jackson.core</groupId>
                    </exclusion>
                </exclusions>
            </dependency>

            <dependency>
                <groupId>com.fasterxml.jackson.datatype</groupId>
                <artifactId>jackson-datatype-jsr310</artifactId>
                <version>2.5.1</version>
            </dependency>

            <!-- JAX-RS/Jersey Impl -->
            <dependency>
                <groupId>org.glassfish.jersey.containers</groupId>
                <artifactId>jersey-container-servlet</artifactId>
                <version>${jersey-servlet.version}</version>
            </dependency>
        </dependencies>
    </profile>
</profiles>

and those are the ws 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>logtec</groupId>
<artifactId>zaprango-ws</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<profiles>
    <profile>
        <id>default</id>

        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>

        <properties>
            <!-- Propriedades do projeto -->
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
            <maven.compiler.fork>true</maven.compiler.fork>

            <!-- Dependencias -->
            <jee.version>7.0</jee.version>
            <qbeasy.version>1.1</qbeasy.version>
            <modelmapper.version>0.7.3</modelmapper.version>
            <maven-compiler.version>1.8</maven-compiler.version>
        </properties>

        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.2</version>
                    <configuration>
                        <source>${maven-compiler.version}</source>
                        <target>${maven-compiler.version}</target>
                    </configuration>
                </plugin>
            </plugins>          
        </build>

        <dependencies>
            <dependency>
                <groupId>br.com.logtec</groupId>
                <artifactId>zaprango-entity</artifactId>
                <version>1.0</version>
            </dependency>

            <!-- JEE 7 API -->
            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
                <version>${jee.version}</version>
            </dependency>

            <!-- Model Mapper -->
            <dependency>
              <groupId>org.modelmapper</groupId>
              <artifactId>modelmapper</artifactId>
              <version>${modelmapper.version}</version>
            </dependency>

            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>1.10</version>
            </dependency>
        </dependencies>

    </profile>

    <profile>
        <id>tomcat</id>

        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>

        <properties>
            <org.postgresql.jdbc.version>9.3-1102-jdbc4</org.postgresql.jdbc.version>
            <weld.version>2.2.4.Final</weld.version>
            <jersey-cdi.version>2.14</jersey-cdi.version>
            <org.hibernate.version>4.3.6.Final</org.hibernate.version>
            <org.hibernate-validator.version>5.1.1.Final</org.hibernate-validator.version>
            <c3p0.version>4.3.8.Final</c3p0.version>
            <deltaspike.version>1.2.1</deltaspike.version>
            <jackson.version>2.16</jackson.version>
        </properties>

        <dependencies>
            <!-- CDI/ Weld Impl -->
            <dependency>
                <groupId>org.jboss.weld.servlet</groupId>
                <artifactId>weld-servlet</artifactId>
                <version>${weld.version}</version>
            </dependency>

            <!-- Possibilitando o uso de de CDI com o Jersey -->
            <dependency>
                <groupId>org.glassfish.jersey.containers.glassfish</groupId>
                <artifactId>jersey-gf-cdi</artifactId>
                <version>${jersey-cdi.version}</version>
            </dependency>

            <!-- JDBC Driver -->
            <dependency>
                <groupId>org.postgresql</groupId>
                <artifactId>postgresql</artifactId>
                <version>${org.postgresql.jdbc.version}</version>
            </dependency>

            <!-- Bean Validation/Hibernate Impl -->
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                <version>${org.hibernate-validator.version}</version>
            </dependency>

            <!-- c3p0 -->
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-c3p0</artifactId>
                <version>${c3p0.version}</version>
            </dependency>
        </dependencies>
    </profile>

    <profile>
        <id>test</id>

        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>

        <properties>
            <junit.junit.version>4.12</junit.junit.version>
            <uk.co.jemos.podam.podam.version>4.7.3.RELEASE</uk.co.jemos.podam.podam.version>
            <arquillian-bom.version>1.1.7.Final</arquillian-bom.version>
            <surefire.version>2.17</surefire.version>
        </properties>

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

                <dependency>
                    <groupId>org.jboss.shrinkwrap.resolver</groupId>
                    <artifactId>shrinkwrap-resolver-bom</artifactId>
                    <version>2.0.0-alpha-5</version>
                    <scope>import</scope>
                    <type>pom</type>
                </dependency>
            </dependencies>
        </dependencyManagement>

        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${surefire.version}</version>
                </plugin>
            </plugins>
        </build>

        <dependencies>
            <!-- JUnit -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.junit.version}</version>
                <scope>test</scope>
            </dependency>

            <!-- Integracao JUnit e Arquillian -->
            <dependency>
                <groupId>org.jboss.arquillian.junit</groupId>
                <artifactId>arquillian-junit-container</artifactId>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
                <version>1.0.0.CR3</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.jboss.weld</groupId>
                <artifactId>weld-core</artifactId>
                <version>1.1.5.Final</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-simple</artifactId>
                <version>1.6.4</version>
            </dependency>

            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.17</version>
            </dependency>

            <dependency>
                <groupId>org.jboss.shrinkwrap.resolver</groupId>
                <artifactId>shrinkwrap-resolver-api</artifactId>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.jboss.shrinkwrap.resolver</groupId>
                <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.jboss.shrinkwrap.resolver</groupId>
                <artifactId>shrinkwrap-resolver-api-maven</artifactId>
                <scope>test</scope>
            </dependency>

            <!-- PoDam -->
            <dependency>
                <groupId>uk.co.jemos.podam</groupId>
                <artifactId>podam</artifactId>
                <version>${uk.co.jemos.podam.podam.version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </profile>
</profiles>

Upvotes: 3

Views: 1088

Answers (1)

Stan
Stan

Reputation: 1430

From my experience this error usually happens when you are using incompatible versions of libraries. Check that all Jersey libraries you are using are compatible and there are no jar of other versions in classpath. I found that class you mentioned is in 'jax-rs-ri' dependency, it could be good start for checking probably. Good luck!

Upvotes: 3

Related Questions