IBM Support

PM94415: Native Query with specified result class can throw NPE when return data contains a null-valued column

Subscribe to this APAR

By subscribing, you receive periodic emails alerting you to the status of the APAR, along with a link to the fix after it becomes available. You can track this item individually or track all items by product.

Notify me when this APAR changes.

Notify me when an APAR for this component changes.

 

APAR status

  • Closed as program error.

Error description

  • This issue is reported and addressed in OPENJPA-2195 -
    
    Native Query with specified result class can throw NPE when
    return data contains a null-valued column
    https://issues.apache.org/jira/browse/OPENJPA-2195
    
    
    When fetching a column from the current row in the ResultSet,
    there is the potential for the value returned to be null
    (through nullable columns or SQL aggregate functions such as MAX
    that can possible return a null value). If there is no
    ResultPacker (such is the case when the query is created without
    a result class type specified), this null value is stored in the
    EagerResultList without any problem.
    
    However, when a result class type is specified when the query is
    created, a ResultPacker is instantiated and used to 'pack' each
    entry fetched from the result set before saving it in the
    EagerResultList's internal List structure. The problem is that
    the ResultPacker.pack(Object result) method is not null-argument
    safe. The first thing the method attempts is try call getClass()
    on its argument, which results in a NullPointerException in this
    situation:
    
    
    java.lang.RuntimeException:
    <openjpa-2.0.2-SNAPSHOT-r422266:1334144M nonfatal user error>
    org.apache.openjpa.persistence.ArgumentException: Failed to
    execute query "select NULLABLE_LNG_DATA FROM JAGNullField WHERE
    NFD_ID =?". Check the query syntax for correctness. See nested
    exception for details.
    at test.SimpleNullTest.test005(SimpleNullTest.java:152)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessor
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethod
    
    
    Caused by: <openjpa-2.0.2-SNAPSHOT-r422266:1334144M nonfatal
    user error> org.apache.openjpa.persistence.ArgumentException:
    Failed to execute query "select NULLABLE_LNG_DATA FROM
    JAGNullField WHERE NFD_ID =?". Check the query syntax for
    correctness. See nested exception for details.
    org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:870)
    org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:792)
    
    Caused by: java.lang.NullPointerException
    org.apache.openjpa.kernel.ResultPacker.pack(ResultPacker.java:19
    org.apache.openjpa.jdbc.kernel.SQLProjectionResultObjectProvider
    .getResultObject(SQLProjectionResultObjectProvider.java:88)
    org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultLis
    org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1246
    

Local fix

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server Liberty Profile                      *
    ****************************************************************
    * PROBLEM DESCRIPTION: When returned data from a native query  *
    *                      contains a null result set, a           *
    *                      NullPointerException is thrown by the   *
    *                      ResultPacker.                           *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    A NullPointerException is thrown by a JPA query operation.  A
    sample caused-by Exception segment is as follows:
    Caused by:
    java.lang.NullPointerException
    at
    org.apache.openjpa.kernel.ResultPacker.pack(ResultPacker.java:19
    6)
    at
    org.apache.openjpa.jdbc.kernel.SQLProjectionResultObjectProvider
    .getResultObject(SQLProjectionResultObjectProvider.java:88)
    at
    org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultLis
    t.java:36)
    at
    org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1246
    )
    at
    org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1005)
    at
    org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:861)
    

Problem conclusion

Temporary fix

Comments

APAR Information

  • APAR number

    PM94415

  • 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-08-02

  • Closed date

    2013-11-11

  • Last modified date

    2013-11-11

  • APAR is sysrouted FROM one or more of the following:

    PM62691

  • 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":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"850","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
11 November 2013