PM91526: EBA JNDI DATASOURCE LOOKUP USING INITIALCONTEXT AND OSGI:SERVICE URL FAILS WITH ILLEGALARGUMENTEXCEPTION.

Subscribe

You can track all active APARs for this component.

APAR status

  • Closed as program error.

Error description

  • The application may fail to start or function correctly. A
    message similar to the following will appear in the log.
    
    Looking up:
    osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/d
    b2)
    [err] java.lang.IllegalArgumentException: [javax.sql.DataSource]
    [err]         at
    org.apache.aries.jndi.services.ServiceHelper.proxyPriviledged(Se
    rviceHelper.java:351)
    [err]         at
    org.apache.aries.jndi.services.ServiceHelper.access$700(ServiceH
    elper.java:66)
    [err]         at
    org.apache.aries.jndi.services.ServiceHelper$1.run(ServiceHelper
    .java:288)
    [err]         at
    java.security.AccessController.doPrivileged(AccessController.jav
    a:229)
    [err]         at
    org.apache.aries.jndi.services.ServiceHelper.proxy(ServiceHelper
    .java:285)
    [err]         at
    org.apache.aries.jndi.services.ServiceHelper.getService(ServiceH
    elper.java:259)
    [err]         at
    org.apache.aries.jndi.url.ServiceRegistryContext.lookup(ServiceR
    egistryContext.java:102)
    [err]         at
    org.apache.aries.jndi.url.ServiceRegistryContext.lookup(ServiceR
    egistryContext.java:144)
    [err]         at
    org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.jav
    a:161)
    [err]         at
    javax.naming.InitialContext.lookup(InitialContext.java:422)
    

Local fix

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All application (EBA) providers using IBM   *
    *                  WebSphere Application Server Liberty        *
    *                  Profile 8.5.5.0 that rely on JNDI resource  *
    *                  look ups using an InitialContext and        *
    *                  osgi:service URL.                           *
    ****************************************************************
    * PROBLEM DESCRIPTION: IllegalArgumentException when           *
    *                      invoking InitialContext.lookup using    *
    *                      an osgi:service URL from within an      *
    *                      application (EBA).                      *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    Features offering JNDI resources advertise the fact by
    registering ResourceFactory services with creates.objectClass
    and osgi.jndi.service.name properties. The blueprint feature
    includes the com.ibm.ws.eba.app.runtime.services bundle which
    listens for ResourceFactory registrations in the root region
    then re-registers them as services within each application's
    region under the interfaces declared by the creates.objectClass
    property and propagates the osgi.jndi.service.name property.
    Applications can then look up JNDI resources using the
    osgi:service URL which includes the desired interface and JNDI
    name referenced by the osgi.jndi.service.name property.
    The move to EBA support via Subsystems caused the service
    providing bundle to become the region context bundle of the
    subsystem. This bundle is a simple placeholder representing the
    boundary of the subsystem's region and does not import any
    packages. The code processing the InitialContext lookup
    requires the service providing bundle to be able to load the
    service class. If it cannot, a ClassNotFoundException occurs
    which is caught and converted into an IllegalArgumentException.
    

Problem conclusion

  • The com.ibm.ws.eba.app.runtime.services bundle was removed
    from the blueprint feature.
    
    The com.ibm.ws.eba.app.runtime.resources bundle was moved from
    the osgi.jpa feature to the blueprint feature. This ensures
    that ResourceFactory registrations are still converted into
    the necessary registrations that match the interfaces defined
    in the creates.objectClass property and include the
    osgi.jndi.service.name property, though this now happens only
    within the root region.
    
    All applications will automatically import all services from
    the root region registered with the osgi.jndi.service.name
    property. This ensures the service providing bundle is now
    always the original provider, which can load the class.
    
    The fix for this APAR is currently targeted for inclusion in
    fix pack 8.5.5.1. Please refer to the Recommended Updates page
    for delivery information:
    http://www.ibm.com/support/docview.wss?rs=180&uid=swg27004980
    

Temporary fix

  • A workaround is to use the BundleContext to look up the service
    directly instead of the JNDI InitialContext and osgi:service
    URL. For example,
    
    DataSource ds = (DataSource)
    bundleContext.getService(bundleContext.getServiceReferences("jav
    ax.sql.DataSource", "(osgi.jndi.service.name=jdbc/db2)")[0]);
    
    rather than
    
    DataSource ds = (DataSource) new InitialContext().lookup(
    "osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/
    db2)");
    
    Note this example is highly simplified and lacks obvious
    safety checks. Moreover, more robust applications would make
    use of OSGi ServiceTracker or ServiceListener.
    

Comments

APAR Information

  • APAR number

    PM91526

  • 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-06-20

  • Closed date

    2013-07-08

  • Last modified date

    2013-08-05

  • 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



Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

WebSphere Application Server

Software version:

850

Reference #:

PM91526

Modified date:

2013-08-05

Translate my page

Machine Translation

Content navigation