JAX-RS Jersey 2.10 support in Websphere 8

26,066

You need to do the following steps:

Disable built in JAX-RS via JVM property com.ibm.websphere.jaxrs.server.DisableIBMJAXRSEngine=true see description here.
You can set this property via web admin console in Servers > WebSphere Application Servers > yourServerName. Then in Server Infrastructure section Java and Process Management > Process definition > Java Virtual Machine > Custom properties.

Create isolated shared library with all JAX-RS 2.10 libraries, in console via Environment > Shared Libraries.

Isolated shared library is created via checking Use an isolated class loader for this shared library Class Loading option, when creating library.

Map this shared library to your application, either during installation or later on, via Applications > appName > Shared library references.

Restart application server. In the SystemOut.log you should see message initializing JAX-RS classes:

[7/12/14 16:10:36:470 CEST] 0000004a JerseyServlet I   Registering the Jersey servlet application, named javax.ws.rs.core.Application, with the following root resource and provider classes: [class jax.Hello, class org.glassfish.jersey.server.wadl.internal.WadlResource]
[7/12/14 16:10:36:688 CEST] 0000004a ApplicationHa I   Initiating Jersey application, version Jersey: 2.10.1 2014-06-30 13:53:32...

UPDATE

It appears that it is also possible to load the JAX-RS jars from within the WAR. You have to set this DisableIBMJAXRSEngine property and you need to change the class loading option in the module (not on EAR level) classloader to Classes loaded with local class loader first (parent last)

In the admin console:

Applications > WebSphere Enterprise Applications > {your.application} > Manage Modules > {your.module}

Change the Class loader order dropdown to: Classes loaded with local class loader first (parent last).

Thanks for dooffas for checking it, see JAX-RS 2.0 WebSphere 8.5 without isolated shared library

Share:
26,066
jerry
Author by

jerry

Updated on July 31, 2022

Comments

  • jerry
    jerry almost 2 years

    I am trying to use Jersey 2.10 in Websphere 8 but it tries to reference the Application which is a implementation of JAX-RS 1.1 (default Wink) I get this below error even though I disabled to JAX-RS default by setting the IBM property.

    Caused by: java.lang.NoSuchMethodError: javax/ws/rs/core/Application.getProperties()Ljava/util/Map; at org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:287) at org.glassfish.jersey.servlet.WebComponent.(WebComponent.java:311)

    I read a post that says to make class loading policy to PARENT_LAST. Changing that option was disabled on WAS console, so I tried using the (Publishing settings for WAS - Run server with resources on Server) and my server got crashed.

    Please advise. Thanks.