user3766874
user3766874

Reputation: 813

Unable to test RESTEasy JAX-RS implementaion for REST API

I have a rest application. My aim is to remove IBM JAX-RS and use RESTEasy JAX-RS implementaion. I am using WAS8 and I want to use only this.

For Disabling IBM JAX-RS, I have removed IBMRestServlet and IBMRestFilter classes and set com.ibm.websphere.jaxrs.server.DisableIBMJAXRSEngine JVM prop to tru in admin console.

For RESTEasy JAX-RS implementaion, Added resteasy-jaxrs dependency in pom and configured servlet in web.xml

       <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jaxrs</artifactId>
        <version>3.0.11.Final</version>
          </dependency>

Web.xml

  <context-param>
     <param-name>resteasy.servlet.mapping.prefix</param-name>
      <param-value>/</param-value>
  </context-param>

  <listener>
  <listener-class>
   org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
   </listener-class>
   </listener>

<servlet>
<servlet-name>resteasy-servlet</servlet-name>
<servlet-class>
  org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
   <init-param>
 <param-name>javax.ws.rs.Application</param-name>
 <param-value>com.application.RestApplication</param-value>
 </init-param>

  </servlet>

  <servlet-mapping>
    <servlet-name>resteasy-servlet</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>

A) Initially I got "java.lang.NoSuchMethodError: org/jboss/resteasy/specimpl/BuiltResponse.getHeaders()" exception. Looking into various answers, added below dependency as first in the pom.xml(though this doesnt make any sense to me)

      <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>jaxrs-api</artifactId>
      <version>3.0.11.Final</version>
      </dependency>

B) Now after this, I am getting java.lang.NoSuchMethodError: javax/ws/rs/ClientErrorException.validate(Ljavax/ws/rs/core/Response;Ljavax/ws/rs/core/Response$Status$Family;Ljavax/ws/rs/core/Response)

Can you help me resolving both A and B exceptions. I want to try this only in WAS8.

Also, How can I be sure that I have disabled IBM JAX-RS completely and server is picking only REST Easy jaxrs.

Upvotes: 1

Views: 833

Answers (1)

Jarid
Jarid

Reputation: 2018

Did you set your web module's class loader to use "Parent last" delegation mode? That's a required part of bringing your own JAX-RS provider in WebSphere. "Disabling" the built-in provider (through the system property you mentioned) prevents it from initializing, but its classes are still visible through the class loader. You'll need to configure your web app's class loader to make sure that it loads local classes first.

Note that if you're worried about the "parent last" setting causing other issues in your app, you can instead throw just your JAX-RS API and implementation into a shared library, set the shared library to use an isolated class loader, and associate that with your web module. It's a bit more targeted (and, thus, safer) way to get that style of class loading.

Upvotes: 3

Related Questions