Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAX-RS implementation on Websphere 8.0.0.6

I understand Websphere 8.0.0.6 uses the Apache Wink implementation for JAX-RS 1.1.

I'm just wondering what version of Apache Wink does it use?

Also, if I needed to use Apache CXF do I just bundle the CXF jars with my war?

ALso what implementations does Websphere 8.0.0.6 use for CDI (Weld 2.x ??), Bean Validation (??), JPA (??), JAXB (??) etc..

like image 389
DarVar Avatar asked Aug 14 '13 17:08

DarVar


1 Answers

WAS v8.0.0.x uses it's own modified version of Wink v1.1-incubating. If you navigate to {WAS_HOME}/plugins, you'll see a .jar named com.ibm.ws.jaxrs.jar. If you explore the MANIFEST within that artifact, you'll see that IBM modified Wink v1.1-incubating and created their own v1.1.1. You'll want to use this version, because it incorporates wink-jcdi-server. Otherwise, you can't inject your EJB's into your Wink Resources, which creates a number of annoying problems. I generally don't like to shackle myself to a vendor-specific solution, but in this case, you're going to want to use IBM's Wink implementation. I've backported wink-jcdi-server from v1.2-incubating to v1.1-incubating with temporary success (I got the jcdi feature to work, but then, with no determined root cause, lost it a few deployments later). So, save yourself tons of frustration and use IMB's Wink implementation. IBM's Wink implementation will be exposed to your app, via an OSGi-related artifact, whether you set the classloader policy to PARENT_FIRST or PARENT_LAST. I suspect that is a bug. You'll also need to include the com.ibm.ws.prereq.jaxrs.jar artifact in your project as well.

In web.xml, use the following config:

<!-- Wink Servlet -->
<servlet>
    <description>JAX-RS Tools Generated - Do not modify</description>
    <servlet-name>JAX-RS Servlet</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.company.webservices.config.WinkApplication</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    <enabled>true</enabled>
    <async-supported>false</async-supported>
</servlet>

<!-- Wink Servlet Mapping -->
<servlet-mapping>
    <servlet-name>JAX-RS Servlet</servlet-name>
    <url-pattern>/resources/*</url-pattern>
</servlet-mapping>

According to IBM's own WAS v8.0 video on JAX-RS, your Application subclass will get automatically recognized by extending the Application class and the ApplicationPath annotation. This is not the case. You need to specify your Application subclass in web.xml. However, you'll notice that the console will tell you that the default Wink Application was used. This is false. Your class will get picked up, and you'll need to override the getClasses method and register your Providers, Resources, etc. This behavior has been observed and thoroughly tested as of WAS v8.0.0.8.

You could try CXF in WAS 8 as an alternative.

Like Geronimo and TomEE, WAS is built on Apache products. I could be wrong, but, last I remember, WAS v8.0 uses Apache OpenWebBeans v1.0, Apache BVal v1.0, Apache OpenJPA v2.1.2-SNAPSHOT. I'm not sure about JAXB, but I think they use their own json4j framework. I use MOXy with surprisingly much success.

like image 142
Chris Harris Avatar answered Dec 17 '22 01:12

Chris Harris