我有一个泽西客户端配置并提出如下请求:
private Response getResponse(Authorization authInstance, String filePath) {
return webResourceInstance.request().header("Authorization",
encode(authInstance)).put(Entity.entity(getFileInStream(filePath), MediaType.APPLICATION_OCTET_STREAM));
}
获得此例外:
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
我看到同样的问题here但是没有接受的答案,我已经在使用jersey-client& jersey-media-json-jackson版本2.25.1。此外,对于此版本,此方法似乎按documentation提供。
早些时候一切正常,但我正在尝试迁移到泽西岛2.x,不确定这是否重要。
答案 0 :(得分:7)
方法org.glassfish.jersey.client.ClientRequest.getLengthLong()
的错误出现在jersey-common-2.25.1.jar
。
因此,如果您使用的是maven
,请在pom.xml
中包含以下依赖项 -
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.25.1</version>
</dependency>