我正在尝试在自由配置文件8.5.5.2上部署RESTful Web服务。我在服务器中启用了jaxrs-1.1
功能,而我正在使用Java 1.7。当我启动服务器时,它会给我以下错误:
[ERROR ] Uncaught.init.exception.thrown.by.servlet
JAX-RS Servlet
accessms
java.lang.NoClassDefFoundError: org/apache/wink/server/handlers/HandlersFactory
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at com.ibm.ws.classloading.internal.AppClassLoader.definePackageAndClass(AppClassLoader.java:275)
at [internal classes]
at org.apache.wink.server.internal.DeploymentConfiguration.initHandlers(DeploymentConfiguration.java:456)
at org.apache.wink.server.internal.DeploymentConfiguration.init(DeploymentConfiguration.java:169)
at org.apache.wink.server.internal.servlet.RestServlet.getDeploymentConfiguration(RestServlet.java:184)
at org.apache.wink.server.internal.servlet.RestServlet.createRequestProcessor(RestServlet.java:129)
at org.apache.wink.server.internal.servlet.RestServlet.init(RestServlet.java:94)
at javax.servlet.GenericServlet.init(GenericServlet.java:161)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:325)
at [internal classes]
[ERROR ] SRVE0266E: Error occured while initializing servlets: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:395)
at [internal classes]
Caused by: java.lang.NoClassDefFoundError: org/apache/wink/server/handlers/HandlersFactory
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at com.ibm.ws.classloading.internal.AppClassLoader.definePackageAndClass(AppClassLoader.java:275)
at [internal classes]
at org.apache.wink.server.internal.DeploymentConfiguration.initHandlers(DeploymentConfiguration.java:456)
at org.apache.wink.server.internal.DeploymentConfiguration.init(DeploymentConfiguration.java:169)
at org.apache.wink.server.internal.servlet.RestServlet.getDeploymentConfiguration(RestServlet.java:184)
at org.apache.wink.server.internal.servlet.RestServlet.createRequestProcessor(RestServlet.java:129)
at org.apache.wink.server.internal.servlet.RestServlet.init(RestServlet.java:94)
at javax.servlet.GenericServlet.init(GenericServlet.java:161)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:325)
... 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>com.example.RestfulResourceLoader</param-value>
</init-param>
<init-param>
<param-name>propertiesLocation</param-name>
<param-value>mobilehandler.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)
WebSphere Liberty支持JAX-RS 1.1,因此您不需要提供servlet类,只需在web.xml中使用以下片段:
<servlet>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
</servlet>
<servlet-mapping>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
另见:
更新
HandlersFactory
来自第三方库,尝试将以下类加载器(在server.xml
中)添加到您的应用程序中以使库可见。
<webApplication... >
<classloader apiTypeVisibility="spec,ibm-api,api,third-party">
</classloader>
</webApplication>