2015-03-31 46 views
3

我重構了一個工作JAX-RS,澤西島實現,webservice爲了隔離它的實體以便它們可以用作庫,我也改變了項目和包的名字,現在當我嘗試獲取Tomcat的我得到這個java.lang.NoSuchMethodError錯誤JAX-RS webservice啓動時出錯

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) 

我用Google搜索,但無法找到與此相關的特定錯誤

這些都是實體項目的依賴任何東西:

<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> 

,而這些都是WS依賴關係:

<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> 

+0

您是否是與Web服務相關的開發人員? – 2015-04-01 11:30:52

+0

好吧,不是初學者..但不是一個老將,但爲什麼? – 2015-04-01 11:40:08

+0

不要在這種情況下使用maven,創建您的動態web項目並將您的jersey jar文件添加到您的WEB-INF/lib文件夾中,並編寫您希望Web服務執行的目的。 – 2015-04-01 11:45:50

回答

3

從我的經驗,這錯誤,當您使用庫的不兼容版本通常發生。檢查您使用的所有Jersey庫是否兼容,並且classpath中沒有其他版本的jar。 我發現你提到的類是'jax-rs-ri'依賴項,它可能是檢查可能的好開始。 祝你好運!

+0

我同意混合版本。 @ MarcosJ.CKichel你應該更新你的帖子以顯示你的依賴關係/罐子 – 2015-04-01 03:08:50

+0

只是做了@peeskillet希望它有幫助 – 2015-04-01 11:24:55

+0

@ MarcosJ.CKichel調查[this](https://jersey.java.net/documentation/latest/migration的.html#米格2.15)。澤西2.15+改變了CDI支持artfiact。 – 2015-04-01 12:32:19