问题
I have deployed the RESTful application using Apache Wink packaged in EAR on WebSphere 8.5.5.2 ND. When the application starts it gives me the "Initialization successful" message:
[5/14/15 15:56:03:588 CDT] 0000006d RestServlet I org.apache.wink.server.internal.servlet.RestServlet getApplication The system is using the my.domain.mobile.rest.RestfulResourceLoader JAX-RS application class that is named in the javax.ws.rs.Application init-param initialization parameter.
[5/14/15 15:56:03:605 CDT] 0000006d SystemOut O 15:56:03,605 INFO [User=] [RestfulResourceLoader] loading resource classes
[5/14/15 15:56:03:684 CDT] 0000006d ApplicationPr I org.apache.wink.server.internal.application.ApplicationProcessor process The following JAX-RS application has been processed: my.domain.mobile.rest.RestfulResourceLoader
[5/14/15 15:56:03:688 CDT] 0000006d Resources I org.apache.wink.server.internal.log.Resources logResourceInfo The server has registered the JAX-RS resource class my.domain.mobile.resources.RestfulLogin with @Path(login).
[5/14/15 15:56:03:690 CDT] 0000006d Providers I org.apache.wink.server.internal.log.Providers log The class my.domain.mobile.RestExceptionHandler was registered as a JAX-RS ExceptionMapper provider for java.lang.Exception Java types.
[5/14/15 15:56:03:974 CDT] 0000006d ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [MyApplication] [/context_root] [JAX-RS Servlet]: Initialization successful.
But as soon as I hit the URL, server gives me below error:
[5/14/15 15:59:55:006 CDT] 000000b5 SystemOut O 15:59:55,006 INFO [User=] [RequestInterceptor] Initializing Request Hanlder
[5/14/15 15:59:55:010 CDT] 000000b5 SystemOut O 15:59:55,010 INFO [User=] [ResponseInterceptor] Initializing response interceptor
[5/14/15 15:59:55:068 CDT] 000000b5 SystemOut O 15:59:55,068 INFO [User=] [RequestInterceptor] URI path "/login" invoked on [my.domain.mobile.resources.RestfulLogin@978a19b]
[5/14/15 15:59:55:070 CDT] 000000b5 RequestProces I org.apache.wink.server.internal.RequestProcessor logException The following error occurred during the invocation of the handlers chain: NoClassDefFoundError with message org.apache.wink.server.internal.handlers.SearchResult while processing POST request sent to http://my.domain.name:81/context_root/rest/login
[5/14/15 15:59:55:071 CDT] 000000b5 RequestProces E org.apache.wink.server.internal.RequestProcessor handleRequest An unhandled exception occurred which will be propagated to the container.
java.lang.NoClassDefFoundError: org.apache.wink.server.internal.handlers.SearchResult
at my.domain.mobile.handler.RequestInterceptor.handleRequest(RequestInterceptor.java:48)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.internal.handlers.CreateInvocationParametersHandler.handleRequest(CreateInvocationParametersHandler.java:54)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.internal.handlers.FindResourceMethodHandler.handleResourceMethod(FindResourceMethodHandler.java:151)
at org.apache.wink.server.internal.handlers.FindResourceMethodHandler.handleRequest(FindResourceMethodHandler.java:65)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.internal.handlers.FindRootResourceHandler.handleRequest(FindRootResourceHandler.java:95)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.internal.handlers.HeadMethodHandler.handleRequest(HeadMethodHandler.java:53)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.internal.handlers.OptionsMethodWADLHandler.handleRequest(OptionsMethodWADLHandler.java:51)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.internal.handlers.SearchResultHandler.handleRequest(SearchResultHandler.java:33)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.internal.log.ResourceInvocation.handleRequest(ResourceInvocation.java:92)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.internal.log.Requests.handleRequest(Requests.java:76)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.handlers.AbstractHandlersChain.run(AbstractHandlersChain.java:60)
at org.apache.wink.server.internal.RequestProcessor.handleRequestWithoutFaultBarrier(RequestProcessor.java:207)
at org.apache.wink.server.internal.RequestProcessor.handleRequest(RequestProcessor.java:154)
at org.apache.wink.server.internal.servlet.RestServlet.service(RestServlet.java:124)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1230)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:779)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:79)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:960)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1064)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3837)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:981)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:283)
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:175)
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:1864)
Caused by: java.lang.ClassNotFoundException: org.apache.wink.server.internal.handlers.SearchResult
at java.net.URLClassLoader.findClass(URLClassLoader.java:600)
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:214)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:772)
at java.lang.ClassLoader.loadClass(ClassLoader.java:749)
at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:120)
at java.lang.ClassLoader.loadClass(ClassLoader.java:726)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:584)
at java.lang.ClassLoader.loadClass(ClassLoader.java:726)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:584)
at java.lang.ClassLoader.loadClass(ClassLoader.java:726)
... 69 more
Earlier I was deploying the same application on WebSphere 7 and it was working fine. I know that WebSphere 8.5 comes with Wink Jars so I removed those jars from EAR and then deployed it on the server. Also, I enabled verbose class loading on my server and found that class is loading when the server starts. Though, when I checked in Class Loader Viewer from console I couldn't found the class. Adding the jars to Shared Library also did not work for me. It would be great help if someone can point me to right direction to solve this error.
Edit
Following statement is giving error inside the handler:
SearchResult result = context.getAttribute(org.apache.wink.server.internal.handlers.SearchResult.class);
回答1:
WAS 8.5 comes with inbuilt Apache Wink 1.1. You can follow these steps to migrate your application on WAS 8.5:
1) Remove all the apache wink jar from your application lib folder.
2) For building your application you can use these two websphere jar, com.ibm.ws.prereq.jaxrs.jar and com.ibm.ws.prereq.jackson.jar. you can find these jars in WAS_HOME/plugins folder.
3) Build your application with these jars but do not package these jars into your application EAR or WAR.
4) If your application type is EAR then Make sure all the restful resources and the class which extends Application class are part of war.
5) Redeploy your application, it should work fine now.
来源:https://stackoverflow.com/questions/30247567/error-invoking-restful-webservice-on-websphere-8-5-5-2-server