Reputation: 1
I am new to RestFul API and came across this https://www.journaldev.com/9189/resteasy-tutorial-eclipse-tomcat. The tutorial is working fine on Tomcat but encounters 404 on WebSphere 8.5. I could see the below printed in SystemOut.log during startup.
[6/9/20 18:15:54:460 SGT] 0000004a ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [backoffice] [/secure/backoffice] [ResteasyServlet]: Initialization successful.
Classloader at application level
No error code found in the J2EE logs but found below error in the web error log. [Thu Jun 11 10:34:57 2020] [error] [client 10.128.1.22] File does not exist: /sldev/scb/dev/ist/web_bkoff/secure/backoffice/rest
I tried below tutorial in IBM website yet I still encounter same issue https://www.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/twbs_jaxrs_getstarted.html
<servlet>
<servlet-name>HelloWorldApp</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.ibm.jaxrs.sample.HelloWorldAppConfig</param-value>
</init-param>
<load-on-startup>9</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorldApp</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
Upvotes: 0
Views: 838
Reputation: 1283
If I had to guess, the problem is most likely that WebSphere 8.5 ships the JAX-RS 1.1 APIs, but the article you referenced uses JAX-RS 2.0. The current version of RESTEasy uses the JAX-RS 2.1 APIs.
RESTEasy implements the JAX-RS APIs. This allows users to code to the JAX-RS APIs, and then run on any compatible implementation - like CXF, Jersey, RESTEasy, etc. But if the implementation is mis-matched with the API version, you can run into problems.
Tomcat does not package any JAX-RS APIs, so it will use the APIs packaged with the application - which should match with what RESTEasy expects. But since WebSphere ships it's own version of the API (and it's own implementation, based on Apache Wink) you are probably running into those problems.
WebSphere v9.0 has the ability to switch API versions to use 2.0, and WebSphere Liberty (or Open Liberty) has the ability to enable/disable different versions of JAX-RS entirely. Unfortunately, WebSphere v8.5 does not have the ability to disable the JAX-RS APIs.
If you can upgrade to v9.0 or switch over to Liberty, that would most likely solve this problem. If upgrading is not an option, you may still be able to make it work in WebSphere v8.5, but it's not a pretty solution: you could use a parent-last classloading delegation so that your application loads the RESTEasy and JAX-RS 2.X API classes from your application's classloader before loading the JAX-RS 1.1/Wink classes from WebSphere's classloader. More information on parent-last here: https://www.ibm.com/support/knowledgecenter/SS7K4U_8.5.5/com.ibm.websphere.zseries.doc/ae/urun_rclassloader_inst.html
Alternatively, you could package the JAX-RS 2.X API JARs and RESTEasy in an isolated shared library and associate that library with the application. Isolated shared libraries are parent-last, but leaves the application classloader at parent-first. More information on isolated shared libraries here: https://www.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.base.iseries.doc/ae/tcws_sharedlib.html
Hope this helps!
Upvotes: 0