WebTarget target = client.target(url); client.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND,true);
Response response = target
.request(MediaType.APPLICATION_JSON_PATCH_JSON)
.header("Authorization", "Bearer " + token)
.method("PATCH", Entity.json(JSONUtils.convertToJSON(List.of(startStopPayload))));
我尝试提出这样的请求, 但收到错误 这是错误:
jakarta.ws.rs.ProcessingException: Unable to make field private final sun.net.www.protocol.https.DelegateHttpsURLConnection sun.net.www.protocol.https.HttpsURLConnectionImpl.delegate accessible: module java.base does not "opens sun.net.www.protocol.https" to unnamed module @47f37ef1
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:309)
at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$0(JerseyInvocation.java:662)
at org.glassfish.jersey.client.JerseyInvocation.call(JerseyInvocation.java:697)
at org.glassfish.jersey.client.JerseyInvocation.lambda$runInScope$3(JerseyInvocation.java:691)
at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
at org.glassfish.jersey.internal.Errors.process(Errors.java:205)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:390)
at org.glassfish.jersey.client.JerseyInvocation.runInScope(JerseyInvocation.java:691)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:661)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:439)
at com.oracle.blockchain.opcp.restserver.client.k8s.K8sBlockchainPlatformInstanceClient.stopInstance(K8sBlockchainPlatformInstanceClient.java:183)
at com.oracle.blockchain.opcp.restserver.client.k8s.K8sBlockchainPlatformInstanceClient$Proxy$_$$_WeldClientProxy.stopInstance(Unknown Source)
at com.oracle.blockchain.opcp.restserver.manager.BPServiceManager.stopBlockchainPlatform(BPServiceManager.java:749)
at com.oracle.blockchain.opcp.restserver.manager.BPServiceManager$Proxy$_$$_WeldSubclass.stopBlockchainPlatform(Unknown Source)
at com.oracle.blockchain.opcp.restserver.manager.BPServiceManager$Proxy$_$$_WeldClientProxy.stopBlockchainPlatform(Unknown Source)
at com.oracle.blockchain.opcp.restserver.resources.BlockchainPlatformResource.stopBlockchainPlatform(BlockchainPlatformResource.java:393)
at com.oracle.blockchain.opcp.restserver.resources.BlockchainPlatformResource$Proxy$_$$_WeldClientProxy.stopBlockchainPlatform(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:134)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:177)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:81)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:478)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:400)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:255)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684)
at io.helidon.webserver.jersey.JerseySupport$JerseyHandler.lambda$doAccept$4(JerseySupport.java:334)
at io.helidon.common.context.Contexts.runInContext(Contexts.java:117)
at io.helidon.common.context.ContextAwareExecutorImpl.lambda$wrap$7(ContextAwareExecutorImpl.java:154)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
我尝试添加
client.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND,true);
我使用的是jdk 17
从 JDK 16 开始,不再可能在 JDK 内部类上使用反射并通过默认 HTTPUrlConnector 将 PATCH 方法添加到支持的 HTTP 方法列表中(这是
client.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND,true);
尝试做的事情。
请从支持的连接器列表中选择另一个连接器来支持 HTTP Patch 方法。