0

© 编写 simole restful webservice 并将该服务部署在 websphere 应用服务器上,

但我得到以下异常:

Error 500: org.jboss.resteasy.spi.UnhandledException: 
    java.lang.ClassCastException: 
       org.apache.wink.common.internal.ResponseImpl incompatible with org.jboss.resteasy.core.ServerRespon

我该如何解决?

谢谢。

日志在这里:

webapp       
 E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[resteasy-servlet]: org.jboss.resteasy.spi.UnhandledException: java.lang.ClassCastException: org.apache.wink.common.internal.ResponseImpl incompatible with org.jboss.resteasy.core.ServerResponse
    at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:241)
    at org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:190)
    at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:534)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1214)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1027)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3703)
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:522)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:311)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:282)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1783)
Caused by: java.lang.ClassCastException: org.apache.wink.common.internal.ResponseImpl incompatible with org.jboss.resteasy.core.ServerResponse
    at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:283)
    at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:220)
    at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:209)
    at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519)

和我的 web.xml 文件

<context-param>
    <param-name>resteasy.resources</param-name>
    <param-value>services.MapService</param-value>
</context-param>

<listener>
    <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>


<servlet>
    <servlet-name>resteasy-servlet</servlet-name>
    <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>resteasy-servlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

4

1 回答 1

3

您正在部署一个与 WebSphere 中包含的(基于 Wink 的)JAX-RS 实现冲突的 Jboss JAX-RS 实现。

切换到内置的 JAX-RS 支持并将 web.xml 更改为引用 JAX-RS 类而不是特定于实现的类,或者将 WebSphere 类加载器更改为 PARENT_LAST 以首先在类路径中获取 Jboss 实现。

如果可以的话,推荐前者。也就是说,写入 JAX-RS 规范而不是它的任何特定实现。(这也将允许您获得 IBM 对 WebSphere 下的 JAX-RS 问题的官方支持。)

于 2013-02-13T13:32:21.260 回答