0
votes

i am using JAX-RS 2.1 and CXF 3.2.6. i have created hello world application and deployed in Webpshere 8.5. it deployed successfully and when i tried to hit am getting below exception. could you help me to resolve this

below is my web.xml

<servlet>
    <servlet-name>JAX-RS Servlet</servlet-name>
    <servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
    <init-param>
      <param-name>javax.ws.rs.Application</param-name>
      <param-value>com.web.ebill.csr.appservice.ServiceApp</param-value>
    </init-param>
    <load-on-startup>-1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>JAX-RS Servlet</servlet-name>
    <url-pattern>/service/*</url-pattern>
  </servlet-mapping>

E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[CXFServlet]: java.lang.NoSuchMethodError: javax/ws/rs/core/Application.getProperties()Ljava/util/Map; (loaded from file:/C:/IBM/WebSphere/AppServer/8.5/plugins/javax.j2ee.jaxrs.jar by org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@a4b360dc) called from class org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet (loaded from file:/C:/workspaces/eblarc/.metadata/.plugins/com.genuitec.eclipse.blue.websphere.core/WebSphere_20_Application_20_Server_20_8_2e_5_20_at_20_localhost_20__28_2_29_/CXFNoSpringDemo/CXFNoSpringDemo/WEB-INF/lib/cxf-rt-frontend-jaxrs-3.2.6.jar by com.ibm.ws.classloader.CompoundClassLoader@3d4f5352[war:CXFNoSpringDemo.ear/CXFNoSpringDemo.war] Local ClassPath: C:\workspaces\eblarc.metadata.plugins\com.genuitec.eclipse.blue.websphere.core\WebSphere_20_Application_20_Server_20_8_2e_5_20_at_20_localhost_20__28_2_29_\CXFNoSpringDemo\CXFNoSpringDemo\WEB-INF\classes;C:\workspaces\eblarc.metadata.plugins\com.genuitec.eclipse.blue.websphere.core\WebSphere_20_Application_20_Server_20_8_2e_5_20_at_20_localhost_20__28_2_29_\CXFNoSpringDemo\CXFNoSpringDemo\WEB-INF\lib\cxf-core-3.2.6.jar;C:\workspaces\eblarc.metadata.plugins\com.genuitec.eclipse.blue.websphere.core\WebSphere_20_Application_20_Server_20_8_2e_5_20_at_20_localhost_20__28_2_29_\CXFNoSpringDemo\CXFNoSpringDemo\WEB-INF\lib\cxf-rt-frontend-jaxrs-3.2.6.jar;C:\workspaces\eblarc.metadata.plugins\com.genuitec.eclipse.blue.websphere.core\WebSphere_20_Application_20_Server_20_8_2e_5_20_at_20_localhost_20__28_2_29_\CXFNoSpringDemo\CXFNoSpringDemo\WEB-INF\lib\cxf-rt-transports-http-3.2.6.jar;C:\workspaces\eblarc.metadata.plugins\com.genuitec.eclipse.blue.websphere.core\WebSphere_20_Application_20_Server_20_8_2e_5_20_at_20_localhost_20__28_2_29_\CXFNoSpringDemo\CXFNoSpringDemo\WEB-INF\lib\javax.ws.rs-api-2.1.1.jar;C:\workspaces\eblarc.metadata.plugins\com.genuitec.eclipse.blue.websphere.core\WebSphere_20_Application_20_Server_20_8_2e_5_20_at_20_localhost_20__28_2_29_\CXFNoSpringDemo\CXFNoSpringDemo Parent: com.ibm.ws.classloader.CompoundClassLoader@108f956b[PF][app:CXFNoSpringDemo.ear] Delegation Mode: PARENT_FIRST). at org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet.isAppResourceLifecycleASingleton(CXFNonSpringJaxrsServlet.java:418) at org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet.createServerFromApplication(CXFNonSpringJaxrsServlet.java:512) at org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet.init(CXFNonSpringJaxrsServlet.java:121) at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:344) at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init(ServletWrapperImpl.java:168) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:636) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:480) 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:97) at com.ibm.controller.InterceptFilter.doFilter(InterceptFilter.java:28) at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:967) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1107) at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3951) at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1014) at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:463) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:530) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:316) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:287) 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:1892)>

1

1 Answers

0
votes

You appear to be attempting to use a 2.1 JAX-RS version (Apache CXF), but because of how class loader delegation works, you're getting the API from the server (WebSphere 8.5.5 includes JAX-RS 1.1). CXFNonSpringJaxrsServlet attempts to call a JAX-RS 2.1 API method that did not exist in 1.1, so the error occurs.

The solution is to change the class loading so that the classes are loaded from your jars instead of the server's jars. There are two ways to do this:

1) Modify the class loader settings of your web module (NOTE: There are also settings for this at the application level, but the jars you care about are in the WAR/web module scope, not the EAR/application), setting the class loader delegation mode to "parent last". That will cause the web module class loader to look in its local class path before delegating the load to its parents.

https://www.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.base.doc/ae/trun_classload_server.html

2) Put the jars you need loaded first into a shared library, select the "use an isolated class loader for this shared library" option, and associate that shared library with the application or web module. That is generally a safer option, because it limits the scope of the parent-last loading to only the jars that need it, although your application appears small enough that it might be overkill in this case. Note that classes in an isolated shared library cannot "see" classes in the EAR/WAR because they get their own separate class loader, so you have to make sure that stuff in the isolated library also has its dependencies there with it.

https://www.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.base.iseries.doc/ae/ucws_rsharedlib_inst.html