2016-11-28 80 views
0

我使用arquillian對Restful java API進行集成測試,這些測試使用@RunAsClient批註執行,應用程序部署在Wildfly 9.java.lang.NoSuchMethodError:org.glassfish.jersey.client.ClientRequest.getLengthLong()J

應用測試正在工作,但突然剎車。

我收到此錯誤:

javax.ws.rs.ProcessingException: org.glassfish.jersey.client.ClientRequest.getLengthLong()J

,這似乎是造成這一個:

Caused by: java.lang.NoSuchMethodError: org.glassfish.jersey.client.ClientRequest.getLengthLong()J

一段代碼:

這是我的朋友:

<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.socialclass</groupId> 
<artifactId>api</artifactId> 
<version>1.0</version> 
<packaging>war</packaging> 

<name>SocialClass API</name> 

<dependencyManagement> 
    <dependencies> 
     <dependency> 
      <groupId>org.jboss.arquillian</groupId> 
      <artifactId>arquillian-bom</artifactId> 
      <version>1.1.11.Final</version> 
      <scope>import</scope> 
      <type>pom</type> 
     </dependency> 
    </dependencies> 
</dependencyManagement> 

<dependencies> 
    <dependency> 
     <groupId>javax</groupId> 
     <artifactId>javaee-api</artifactId> 
     <version>7.0</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-core</artifactId> 
     <version>4.3.0.Final</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
     <version>1.7.5</version> 
    </dependency> 

    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-log4j12</artifactId> 
     <version>1.7.5</version> 
    </dependency> 

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

    <dependency> 
     <groupId>commons-lang</groupId> 
     <artifactId>commons-lang</artifactId> 
     <version>2.3</version> 
    </dependency> 

    <dependency> 
     <groupId>net.sargue</groupId> 
     <artifactId>mailgun</artifactId> 
     <version>1.2.0</version> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.deltaspike.core</groupId> 
     <artifactId>deltaspike-core-api</artifactId> 
     <version>${deltaspike.version}</version> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.deltaspike.core</groupId> 
     <artifactId>deltaspike-core-impl</artifactId> 
     <version>${deltaspike.version}</version> 
     <scope>runtime</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.deltaspike.modules</groupId> 
     <artifactId>deltaspike-jpa-module-api</artifactId> 
     <version>${deltaspike.version}</version> 
     <scope>compile</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.deltaspike.modules</groupId> 
     <artifactId>deltaspike-jpa-module-impl</artifactId> 
     <version>${deltaspike.version}</version> 
     <scope>runtime</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.deltaspike.modules</groupId> 
     <artifactId>deltaspike-data-module-api</artifactId> 
     <version>${deltaspike.version}</version> 
     <scope>compile</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.deltaspike.modules</groupId> 
     <artifactId>deltaspike-data-module-impl</artifactId> 
     <version>${deltaspike.version}</version> 
     <scope>runtime</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.deltaspike.modules</groupId> 
     <artifactId>deltaspike-bean-validation-module-impl</artifactId> 
     <version>${deltaspike.version}</version> 
    </dependency> 

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

    <dependency> 
     <groupId>com.nimbusds</groupId> 
     <artifactId>nimbus-jose-jwt</artifactId> 
     <version>3.9</version> 
     <exclusions> 
      <exclusion> 
       <artifactId>bcprov-jdk15on</artifactId> 
       <groupId>org.bouncycastle</groupId> 
      </exclusion> 
     </exclusions> 
    </dependency> 

    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-validator</artifactId> 
     <version>5.3.0.Alpha1</version> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-jaxrs</artifactId> 
     <version>3.0.11.Final</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.8.1</version> 
     <scope>test</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.arquillian.junit</groupId> 
     <artifactId>arquillian-junit-container</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.wildfly</groupId> 
     <artifactId>wildfly-arquillian-container-managed</artifactId> 
     <version>8.2.1.Final</version> 
     <exclusions> 
      <exclusion> 
       <groupId>sun.jdk</groupId> 
       <artifactId>jconsole</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.arquillian.protocol</groupId> 
     <artifactId>arquillian-protocol-servlet</artifactId> 
     <scope>test</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.flywaydb</groupId> 
     <artifactId>flyway-core</artifactId> 
     <version>4.0.3</version> 
    </dependency> 

    <dependency> 
     <groupId>org.glassfish.jersey.media</groupId> 
     <artifactId>jersey-media-json-jackson</artifactId> 
     <version>2.22</version> 
    </dependency> 
</dependencies> 

<properties> 
    <war.name>api</war.name> 
    <deltaspike.version>1.5.1</deltaspike.version> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <maven.compiler.fork>true</maven.compiler.fork> 
</properties> 

<build> 
    <finalName>${war.name}</finalName> 

    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <configuration> 
       <source>1.8</source> 
       <target>1.8</target> 
      </configuration> 
     </plugin> 

     <plugin> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.17</version> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.6</version> 
      <configuration> 
       <failOnMissingWebXml>false</failOnMissingWebXml> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

+0

你能找到並分享你的代碼中使用的方法嗎?或者分享整個類/堆棧跟蹤的異常 – nullpointer

回答

0

他們最近更新的GlassFish代碼並取消ClientRequest.getLengthLong()和更新的HttpURLConnection類代碼https://github.com/jersey/jersey/commit/4275389f727813aba883a7898f74948b8528018c

如果您更新

<dependency> 
    <groupId>org.glassfish.jersey.media</groupId> 
    <artifactId>jersey-media-json-jackson</artifactId> 
    <version>2.22</version> 
</dependency> 

到最新的版本(或做<version>[2.22,3.0)</version>)應該解決所有的問題。