【问题标题】:runtime exception while calling rest service using reast-easy使用 rest-easy 调用休息服务时出现运行时异常
【发布时间】:2019-11-06 05:08:42
【问题描述】:

应用程序是带有 EJB 绑定和 WAS 7 部署的 Spring 3.1.0。

尝试使用以下实现的 resteasy-jaxrs 和 jaxrs-api jar 调用 Rest Service 端点。但无法调用端点,得到RunTimeException如下:

java.lang.RuntimeException: java.lang.ClassNotFoundException: com.sun.ws.rs.ext.RuntimeDelegateImpl

引起: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>

调用rest Endpoint的代码:

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);

任何人都可以就上述问题提出建议。

【问题讨论】:

    标签: java spring rest resteasy


    【解决方案1】:

    RuntimeDelegateImpl 是 resteasy-client 包的一部分。您需要在 pom.xml 中声明对 resteasy-client 的依赖

    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-client</artifactId>
    </dependency>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-05
      • 1970-01-01
      • 2014-01-21
      • 1970-01-01
      • 2010-12-11
      • 1970-01-01
      • 2017-09-01
      • 1970-01-01
      相关资源
      最近更新 更多