[英]Jersey Client NoSuchMethodError: org.glassfish.jersey.client.ClientRequest.getLengthLong()J
I have a jersey client configured and making request as follows: 我已经配置了球衣客户端,并发出如下请求:
private Response getResponse(Authorization authInstance, String filePath) {
return webResourceInstance.request().header("Authorization",
encode(authInstance)).put(Entity.entity(getFileInStream(filePath), MediaType.APPLICATION_OCTET_STREAM));
}
Getting this exception: 得到这个异常:
javax.ws.rs.ProcessingException: org.glassfish.jersey.client.ClientRequest.getLengthLong()J
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:261)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:684)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:681)
at 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)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:681)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:437)
at org.glassfish.jersey.client.JerseyInvocation$Builder.put(JerseyInvocation.java:326)
at oracle.esscs.rest.core.REST_PUTProcessor.getResponse(REST_PUTProcessor.java:139)
at oracle.esscs.rest.core.REST_PUTProcessor.execRequest(REST_PUTProcessor.java:123)
at oracle.esscs.rest.setup.FilesUtils.uploadFiletoUserDir(FilesUtils.java:73)
at oracle.esscs.rest.tests.cubedesigner.TestBSOTemplates.testBSOTemplates(TestBSOTemplates.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:645)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:756)
at org.testng.TestRunner.run(TestRunner.java:610)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)
at org.testng.TestNG.runSuites(TestNG.java:1133)
at org.testng.TestNG.run(TestNG.java:1104)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
Caused by: java.lang.NoSuchMethodError: org.glassfish.jersey.client.ClientRequest.getLengthLong()J
at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:364)
at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:285)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:252)
... 38 more
I saw the same question here but there is no accepted answer and I am already using jersey-client & jersey-media-json-jackson version 2.25.1. 我在这里看到了相同的问题,但没有可接受的答案,我已经在使用jersey-client&jersey-media-json-jackson版本2.25.1。 Also, the method seems to be available as per documentation for this version.
此外,该方法似乎可以根据该版本的文档使用。
Everything was working fine earlier but I am trying to migrate to Jersey 2.x, not sure if that's important. 之前一切正常,但是我正在尝试迁移到Jersey 2.x,不确定这是否重要。
The error you got for the method org.glassfish.jersey.client.ClientRequest.getLengthLong()
is present in jersey-common-2.25.1.jar
. 在
jersey-common-2.25.1.jar
存在方法org.glassfish.jersey.client.ClientRequest.getLengthLong()
jersey-common-2.25.1.jar
。
So, if you are using maven
, include following dependency in your pom.xml
- 因此,如果您使用的是
maven
,则在pom.xml
包括以下依赖项-
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.25.1</version>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.