IBM Support

PI05977: EJB-IN-WAR INJECTION (JAX-RS) CAUSES A CLASSCASTEXCEPTION

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Invoke method of SecurityContext in a EJB-in-WAR JAX-RS
    application may cause a ClassCastException
    

Local fix

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server Liberty Profile who use EJB in WAR   *
    ****************************************************************
    * PROBLEM DESCRIPTION: Invoking methods of                     *
    *                      javax.ws.rs.core.SecurityContext in a   *
    *                      EJB-in-WAR JAX-RS application will      *
    *                      cause a ClassCastException              *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    When using injection in an EJB-in-WAR JAX-RS application with
    annotation below:
    @javax.ws.rs.core.Context ‚  
    javax.ws.rs.core.SecurityContext context; ‚  
    And invoke methods of javax.ws.rs.core.SecurityContext, an
    exception will be thrown:
    Caused by: java.lang.ClassCastException:
    com.ibm.ejs.csi.EJBModuleMetaDataImpl incompatible with
    com.ibm.wsspi.webcontainer.metadata.WebModuleMetaData
     ‚  
    The root cause of this problem is: once the code gets the EJB
    instances from EJB container, the context metadata is updated,
    while the runtime codes may still use HttpServletRequest to
    read the corresponding information.
    

Problem conclusion

  • To fix the problem, the solution is to save the web module
    metadata, and create a new class
    JAXRSHttpServletRequestAdapter that implements
    HttpServletRequest and override the methods. In each method,
    we recover web module metadata before invoking the target
    method in HttpServletRequest:
    
    public class JAXRSHttpServletRequestAdapter implements
    HttpServletRequest {
    
        ......
    
        @Override
        public Object getAttribute(String arg0) {
            try {
                collaborator.preInvoke(componentMetaData);
                return request.getAttribute(arg0);
            } finally {
                collaborator.postInvoke();
            }
        }
        ......
    }
    
    The fix for this APAR is currently targeted for inclusion in
    fix pack 8.5.5.2. Please refer to the Recommended Updates page
    for delivery information:
    http://www.ibm.com/support/docview.wss?rs=180&uid=swg27004980
    

Temporary fix

Comments

APAR Information

  • APAR number

    PI05977

  • Reported component name

    LIBERTY PROFILE

  • Reported component ID

    5724J0814

  • Reported release

    850

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2013-11-12

  • Closed date

    2013-12-04

  • Last modified date

    2013-12-04

  • 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

    LIBERTY PROFILE

  • Fixed component ID

    5724J0814

Applicable component levels

  • R850 PSY

       UP

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"850","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
28 April 2022