IBM Support

PH02024: ZWAS CDI BEANBANAGER.GETBEANS() SHOULD NOT FILTER OUT NON-ALTERNATIVES

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Customer reports using a kind of Service Registry pattern with
    CDI, having a Service  Qualifier annotation that we use with the
    CDI BeanManager as specified by the standard like:
    --
    @Inject
    private BeanManager beanManager;
    
    final Bean<?> bean = beanManager.getBeans(Object.class, new
    AnnotationLiteral<Service>(){}).iterator().next();
    final T service = (T) beanManager.getReference(bean, bean.
    getBeanClass(), beanManager.createCreationalContext(bean));
    --
    An @Alternative annotated bean was added to the application
    EAR declared so as well in its beans.xml:
    --
    <alternatives>
    
    <class>com.mycompany.impl.AlternativeDispatcherImpl</class>
    </alternatives>
    --
    Adding this statement to the XML results in an empty
    Set<Bean<?>> being
    returned by beanManager.getBeans().
    
    Removing the statement results in the old, desired behavior of
    returning all @Service annotated beans.
    L3 were able to recreate the issue as follows:
    --
    The issue is caused by getBeans() going through the same routine
    as regular injection. In regular injection enabled Alternatives
    do take priority over everything else, but for getBeans() that
    is not desirable.
    BeanBanager.getBeans() should not filter out non-alternatives.
    

Local fix

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server V8.5                                 *
    ****************************************************************
    * PROBLEM DESCRIPTION: When application code calls             *
    *                      BeanManager.getBeans() only             *
    *                      Alternative beans are returned if an    *
    *                      Alterantive is present                  *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    The CDI specification requires that beans annoated Alternative
    take precedent over unannotated beans, if the alternative is
    enabled. Becuaes BeanManager.getBeans() is used by CDI's
    internal code it hard codes this spec requirement. This
    results in incorrect behaviour
    

Problem conclusion

  • A new system property,
    com.ibm.ws.webbeans.getBeansFilterNonAlternatives, was added
    with a default of false. If set to true and an enabled
    @Alternative bean exists in the results; only enabled
    @Alternatives will be returned. Otherwise all matching beans
    will be returned.
    
    The fix for this APAR is currently targeted for inclusion in
    fix pack 8.5.5.15 and liberty 19.0.0.1.  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

    PH02024

  • Reported component name

    WEBSPHERE FOR Z

  • Reported component ID

    5655I3500

  • Reported release

    850

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2018-08-22

  • Closed date

    2019-02-28

  • Last modified date

    2019-02-28

  • 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

    WEBSPHERE FOR Z

  • Fixed component ID

    5655I3500

Applicable component levels

  • R850 PSY

       UP

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

Document Information

Modified date:
27 April 2022