This repository has been archived by the owner on Jan 27, 2021. It is now read-only.
Fix for CDI Component Initialization on IBM WebSphere 8.5.5.12 Update #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
After upgrading to IBM WebSphere Update 8.5.5.12, startup errors occur due to initialization error of the Jersey (JAX-RS) v.1.17.1 libraries, failing to setup the REST endpoints.
Reason
The the reason for the problem is that the initialization phase of the Jersey (v1.17.1), is accessing the java:comp/BeanManager from JNDI.
In the IBM WebSphere 8.5.5.12 Update, the fix APR PI66630 UnsatisfiedResolutionException thrown in non-CDI environment , changes the behaviour and returns an object of javax.naming.Reference, instead of previously throwing an UnsatisfiedResolutionException. (http://www-01.ibm.com/support/docview.wss?rs=180&uid=swg1PI66630)
This causes a java.lang.ClassCastException: javax.naming.Reference incompatible with javax.enterprise.inject.spi.BeanManager in the class com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory constructor which is not caught, breaking the Jersey initialization, stopping the subsequent initialization to progress.
See: https://github.com/jersey/jersey-1.x/blob/1.19.3/jersey-servlet/src/main/java/com/sun/jersey/server/impl/cdi/CDIComponentProviderFactory.java#L90
The change in code involved capturing the exception and logging the problem, however still continuing with other initialization, invoked from https://github.com/jersey/jersey-1.x/blob/1.19.3/jersey-servlet/src/main/java/com/sun/jersey/spi/container/servlet/WebComponent.java#L572