应用程序是 Spring 3.1.0,具有 EJB 绑定(bind)和 WAS 7 部署。
尝试使用带有以下实现的resteasy-jaxrs和jaxrs-api jar来调用Rest Service端点。但无法调用端点,得到 RunTimeException 如下:
java.lang.RuntimeException: java.lang.ClassNotFoundException: com.sun.ws.rs.ext.RuntimeDelegateImpl
Caused by: java.lang.ClassNotFoundException: com.sun.ws.rs.ext.RuntimeDelegateImpl
pom中使用的依赖项是
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
调用休息端点的代码:
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpParams params = httpClient.getParams();
String serviceTimeout = "180000";
HttpConnectionParams.setConnectionTimeout(params,
Integer.parseInt(serviceTimeout));
HttpConnectionParams.setSoTimeout(params,
Integer.parseInt(serviceTimeout));
ClientExecutor clientExecutor = new
ApacheHttpClient4Executor(httpClient);
ClientRequest clientRequest = new ClientRequest("url",
clientExecutor);
clientRequest.body(MediaType.APPLICATION_XML, xml);
logger.debug("Sending request :");
ClientResponse<String> clientResponse =
clientRequest.post(String.class);
任何人都可以对上述问题提出建议吗?
最佳答案
RuntimeDelegateImpl
是resteasy-client 包的一部分。您需要声明对 resteasy-client 的依赖关系在您的 pom.xml
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
</dependency>
关于java - 使用 east-easy 调用 Rest 服务时出现运行时异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56735787/