我在Java 1.8上使用Liberty配置文件16并启用了以下功能:
<featureManager>
<feature>jsp-2.3</feature>
<feature>wasJmsServer-1.0</feature>
<feature>wasJmsClient-2.0</feature>
<feature>jndi-1.0</feature>
<feature>ejbLite-3.2</feature>
<feature>servlet-3.1</feature>
<feature>jdbc-4.0</feature>
<feature>localConnector-1.0</feature>
<feature>jaxrs-2.0</feature>
</featureManager>
我正在使用Apache Wink作为我的休息提供者,并将其添加为第三方库。
<library id="winkLib" >
<fileset dir="E:\Software\Jars\wink1.4\apache-wink-1.4\lib" includes="*.jar" scanInterval="5s"></fileset>
</library>
<enterpriseApplication location="E:\wlp9\usr\servers\servername\apps\myear.ear">
<classloader commonLibraryRef="winkLib" />
</enterpriseApplication>
REST服务已成功注册,但当我尝试访问该服务时,我收到以下错误:
10:43:04,241 INFO [User=] [RequestInterceptor] Initializing Request Hanlder
10:43:04,256 INFO [User=] [ResponseInterceptor] Initializing response interceptor
[INFO ] The following error occurred during the invocation of the handlers chain: NullPointerException with message 'null' while processing POST request sent to http://localhost:8081/myapp/rest/login
10:43:04,287 WARN [User=] [RestExceptionHandler] Exception Hanlder Invoked
10:43:04,287 ERROR [User=] [RestExceptionHandler]
****************************************************************************************************
Message Info:java.lang.NullPointerException
****************************************************************************************************
[ERROR ] The system cannot determine the class of type null.
[ERROR ] An unhandled exception occurred which will be propagated to the container.
java.lang.NullPointerException
[ERROR ] SRVE0777E: Exception thrown by application class 'java.lang.Class.isAssignableFrom:-2'
java.lang.NullPointerException
at java.lang.Class.isAssignableFrom(Native Method)
at org.apache.wink.common.internal.registry.ProvidersRegistry$MediaTypeMap$OFHolder.compareTo(ProvidersRegistry.java:1008)
at org.apache.wink.common.internal.registry.ProvidersRegistry$MediaTypeMap$OFHolder.compareTo(ProvidersRegistry.java:906)
at java.util.Collections$ReverseComparator.compare(Collections.java:5117)
at java.util.Collections$ReverseComparator.compare(Collections.java:5108)
at java.util.TreeMap.put(TreeMap.java:552)
at java.util.TreeSet.add(TreeSet.java:255)
at org.apache.wink.common.internal.registry.ProvidersRegistry$MediaTypeMap.internalGetProvidersByMediaType(ProvidersRegistry.java:752)
at org.apache.wink.common.internal.registry.ProvidersRegistry$MediaTypeMap.getProvidersByMediaType(ProvidersRegistry.java:711)
at org.apache.wink.common.internal.registry.ProvidersRegistry.getMessageBodyWriter(ProvidersRegistry.java:445)
at org.apache.wink.common.internal.contexts.ProvidersImpl.getMessageBodyWriter(ProvidersImpl.java:72)
at org.apache.wink.server.internal.handlers.FlushResultHandler.handleResponse(FlushResultHandler.java:144)
at org.apache.wink.server.handlers.AbstractHandler.handleResponse(AbstractHandler.java:38)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:26)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.handlers.AbstractHandler.handleResponse(AbstractHandler.java:39)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:26)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.handlers.AbstractHandler.handleResponse(AbstractHandler.java:39)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:26)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.handlers.AbstractHandler.handleResponse(AbstractHandler.java:39)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:26)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.internal.log.Responses.handleResponse(Responses.java:90)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:26)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.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:232)
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:790)
at [internal classes]
[INFO ] FFDC1015I: An FFDC Incident has been created: "java.lang.NullPointerException com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters 1105" at ffdc_17.03.09_10.43.04.0.log
[ERROR ] SRVE0315E: An exception occurred: java.lang.Throwable: java.lang.NullPointerException
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4983)
at [internal classes]
Caused by: java.lang.NullPointerException
at java.lang.Class.isAssignableFrom(Native Method)
at org.apache.wink.common.internal.registry.ProvidersRegistry$MediaTypeMap$OFHolder.compareTo(ProvidersRegistry.java:1008)
at org.apache.wink.common.internal.registry.ProvidersRegistry$MediaTypeMap$OFHolder.compareTo(ProvidersRegistry.java:906)
at java.util.Collections$ReverseComparator.compare(Collections.java:5117)
at java.util.Collections$ReverseComparator.compare(Collections.java:5108)
at java.util.TreeMap.put(TreeMap.java:552)
at java.util.TreeSet.add(TreeSet.java:255)
at org.apache.wink.common.internal.registry.ProvidersRegistry$MediaTypeMap.internalGetProvidersByMediaType(ProvidersRegistry.java:752)
at org.apache.wink.common.internal.registry.ProvidersRegistry$MediaTypeMap.getProvidersByMediaType(ProvidersRegistry.java:711)
at org.apache.wink.common.internal.registry.ProvidersRegistry.getMessageBodyWriter(ProvidersRegistry.java:445)
at org.apache.wink.common.internal.contexts.ProvidersImpl.getMessageBodyWriter(ProvidersImpl.java:72)
at org.apache.wink.server.internal.handlers.FlushResultHandler.handleResponse(FlushResultHandler.java:144)
at org.apache.wink.server.handlers.AbstractHandler.handleResponse(AbstractHandler.java:38)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:26)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.handlers.AbstractHandler.handleResponse(AbstractHandler.java:39)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:26)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.handlers.AbstractHandler.handleResponse(AbstractHandler.java:39)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:26)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.handlers.AbstractHandler.handleResponse(AbstractHandler.java:39)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:26)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:22)
at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75)
at org.apache.wink.server.internal.log.Responses.handleResponse(Responses.java:90)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.java:26)
at org.apache.wink.server.handlers.ResponseHandlersChain.handle(ResponseHandlersChain.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:232)
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:790)
... 1 more
这是我的web.xml看起来像:
<servlet>
<servlet-name>JAX-RS Servlet</servlet-name>
<servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>package.name.RestfulResourceLoader</param-value>
</init-param>
<init-param>
<param-name>propertiesLocation</param-name>
<param-value>handler.properties</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
答案 0 :(得分:1)
这看起来像Wink中的一个错误。虽然您的共享库建议您使用Wink 1.4,但堆栈跟踪中的源代码行号更接近于Wink 1.2.1。也许这个问题在Wink的更新版本中得到了解决。
您的配置肯定容易出错,因为您使用的是jaxrs-2.0功能(其中包括告诉Liberty服务器使JAX-RS 2.0 API包可供应用程序使用),但尝试使用不同的JAX- RS提供商。此处还存在版本冲突 - Wink实现了JAX-RS 1.1。如果我正确理解此配置,您使用Wink作为JAX-RS提供程序,但使用Liberty附带的JAX-RS 2.0 API。即使这不是您所看到的问题的原因,也可能会在以后引起问题。
如果您想使用Wink,我建议您从应用程序中删除它,然后使用jaxrs-1.1功能(而不是jaxrs-2.0功能)。 Liberty的jaxrs-1.1。实现是Wink,它使许多特定于Wink的API可用。
如果您只需要一个JAX-RS提供程序(没有特定于Wink),那么我建议您从应用程序中删除Wink库,并使用内置于jaxrs-2.0功能的CXF实现。这需要制作一些changes to the web.xml。
希望这有帮助,Andy