APAR status
Closed as program error.
Error description
If a customer attempts to perform CDI injection using the @Inject annotation on the constructor of a JAX-RS resource class, injection will not occur unless the class is annotated with a CDI scope annotation. Previously, user's did not have to annotate their classes.
Local fix
Problem summary
**************************************************************** * USERS AFFECTED: ALL * **************************************************************** * PROBLEM DESCRIPTION: JAX-RS applications which use CDI * * constructor injection to inject fields * * into their JAX-RS resource class do not * * perform injection resulting in a * * NullPointerException when the field is * * used. * **************************************************************** * RECOMMENDATION: * **************************************************************** Customer's application code throws a NullPointerException and the JAX-RS request returns an HTTP 500 when attempting to use an object in their JAX-RS resource class which is injected via CDI constructor injection. @Path("cdiresource") public class CDIResource { // This is a JAX-RS resource class private ClassA classA; // This object never gets injected public CDIResource() {} @Inject public CDIResource(ClassA classA) { this.classA = classA; } @GET @Path("get") @Produces(MediaType.APPLICATION_JSON) public Response get() { return Response.ok().entity(classA.message()).build(); /// NullPointerException trying to call classA.message() } }
Problem conclusion
To perform CDI constructor injection on JAX-RS resource classes, reverted to getting the object from CDI the old way when the class is not a Weld proxy. The fix for this APAR is currently targeted for inclusion in fix pack 20.0.0.6. Please refer to the Recommended Updates page for delivery information: http://www.ibm.com/support/docview.wss?rs=180&uid=swg27004980
Temporary fix
Annotate the JAX-RS resource class with the @Dependent CDI annotation.
Comments
APAR Information
APAR number
PH25479
Reported component name
WAS LIBERTY COR
Reported component ID
5725L2900
Reported release
CD0
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt / Xsystem
Submitted date
2020-05-15
Closed date
2020-05-21
Last modified date
2020-06-02
APAR is sysrouted FROM one or more of the following:
APAR is sysrouted TO one or more of the following:
Fix information
Fixed component name
WAS LIBERTY COR
Fixed component ID
5725L2900
Applicable component levels
[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSD28V","label":"WebSphere Application Server Liberty Core"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Line of Business":{"code":"LOB45","label":"Automation"}}]
Document Information
Modified date:
02 June 2020