5

I am using Jersey 2 to implement JAR-RS 2.0 in an IBM WebSphere 8.5 environment.

After reading this post JAX-RS Jersey 2.10 support in Websphere 8 I managed to get this working.

However, is it possible to bundle the JAX-RS Jars within the WAR and deploy the application without the need to create an isolated shared library? If this is not possible, can someone please explain why this is the case?

I understand the deployment time advantage of having the Jars in a library, but I would prefer to build the entire application including dependencies into a single WAR.

-- EDIT --

It appears that you can load the JAX-RS jars from within the WAR if you change the class loading order. You need to change the order to load classes parent last. This can be done as follows;

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)".

This however suggests that some JVM properties are missing from the attached Stackoverflow article.

Can anyone shed some light on the situation?

Community
  • 1
  • 1
dooffas
  • 474
  • 9
  • 18
  • Looks like you are right, setting `Parent Last` on the `Module level` and setting `com.ibm.websphere.jaxrs.server.DisableIBMJAXRSEngine=true` allows to use Jersey without isolated shared library. I'll update that post you are referring to. – Gas Apr 15 '15 at 23:30
  • After setting the com.ibm.websphere.jaxrs.server.DisableIBMJAXRSEngine=true property in AS level and setting the parent_last class loader in the module, I get following error during application startup: Caused by: java.util.ServiceConfigurationError: javax.servlet.ServletContainerInitializer: Provider org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer not a subtype at java.util.ServiceLoader.fail(ServiceLoader.java:250) at java.util.ServiceLoader.access$300(ServiceLoader.java:196) at java.util.ServiceLoader$LazyIterator.nextService – Rajib Biswas May 17 '18 at 04:52

1 Answers1

8

It appears that you can load the JAX-RS jars from within the WAR if you change the class loading order. You need to change the order to load classes parent last. This can be done as follows;

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)".

dooffas
  • 474
  • 9
  • 18
  • Hi @dooffas, can you please share which implementation of jax-rs 2.0 have you used when you performed above? Thank you. – Anatoly Feb 25 '16 at 21:17
  • I was using Jersey 2. If you are using the bundle from the Jersey website, ensure you don't include the servlet API jar that with the bundle. – dooffas Feb 26 '16 at 06:38
  • @dooffas, After setting the com.ibm.websphere.jaxrs.server.DisableIBMJAXRSEngine=true property in AS level and setting the parent_last class loader in the module, I get following error during application startup: Caused by: java.util.ServiceConfigurationError: javax.servlet.ServletContainerInitializer: Provider org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer not a subtype at java.util.ServiceLoader.fail(ServiceLoader.java:250) at java.util.ServiceLoader.access$300(ServiceLoader.java:196) at java.util.ServiceLoader$LazyIterator.nextService – Rajib Biswas May 17 '18 at 04:54