java.lang.NoSuchMethodError:javax.ws.rs.core.Response $ Status $ Family

时间:2017-03-22 09:06:24

标签: java web-services maven jax-rs jersey-2.0

使用

时,Javax客户端会出现以下错误
Builder request = webTarget.request();
return request.get();
  

javax.ws.rs.ProcessingException:   javax.ws.rs.core.Response $状态$ Family.familyOf(I)Ljavax / WS / RS /核心/响应$状态$家庭;     在   org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:263)     在   org.glassfish.jersey.client.JerseyInvocation $ 1.call(JerseyInvocation.java:671)     在   org.glassfish.jersey.client.JerseyInvocation $ 1.call(JerseyInvocation.java:668)     在org.glassfish.jersey.internal.Errors.process(Errors.java:315)at   org.glassfish.jersey.internal.Errors.process(Errors.java:297)at   org.glassfish.jersey.internal.Errors.process(Errors.java:228)引起的   by:java.lang.NoSuchMethodError:   javax.ws.rs.core.Response $状态$ Family.familyOf(I)Ljavax / WS / RS /核心/响应$状态$家庭;     在   org.glassfish.jersey.message.internal.Statuses $ StatusImpl。(Statuses.java:63)     在   org.glassfish.jersey.message.internal.Statuses $ StatusImpl。(Statuses.java:54)     在   org.glassfish.jersey.message.internal.Statuses.from(Statuses.java:143)     在   org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:338)     在   org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:242)     在   org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:254)

这可能是因为Javax客户端版本,仅在执行期间没有编译错误我看到上述异常

POM:

<dependency>
                <groupId>org.testng</groupId>
                <artifactId>testng</artifactId>
                <version>6.9.4</version>
                <scope>test</scope>
            </dependency>
                <dependency>
                <groupId>org.fluttercode.datafactory</groupId>
                <artifactId>datafactory</artifactId>
                <version>0.8</version>
                <type>jar</type>
            </dependency>

            <!-- ObjectMapper dependencies start .. -->

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


            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>4.5</version>
            </dependency>

            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpmime</artifactId>
                <version>4.2.4</version>
            </dependency>

            <dependency>
                <groupId>com.jayway.restassured</groupId>
                <artifactId>rest-assured</artifactId>
                <version>2.4.1</version>
                <scope>test</scope>
            </dependency>


            <!-- ObjectMapper dependencies End.. -->
            <dependency>
                <groupId>org.glassfish.jersey.core</groupId>
                <artifactId>jersey-client</artifactId>
                <version>2.19</version>
            </dependency>

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

            <dependency>
                <groupId>org.glassfish.jersey.media</groupId>
                <artifactId>jersey-media-multipart</artifactId>
                <version>2.19</version>
                <exclusions>
                    <exclusion>
                        <groupId>javax.ws.rs</groupId>
                        <artifactId>javax.ws.rs-api</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>


         <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-jaxws</artifactId>
            <version>1.6.2</version>
            <scope>runtime</scope>
            <exclusions>
               <!--  Causes java.lang.NoSuchMethodError: javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family; -->
                <exclusion>
                    <groupId>javax.ws.rs</groupId>
                    <artifactId>jsr311-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency> 

0 个答案:

没有答案