IBM Support

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

Fixes are available

8.0.0.8: WebSphere Application Server V8.0 Fix Pack 8
8.5.5.2: WebSphere Application Server V8.5.5 Fix Pack 2
8.0.0.9: WebSphere Application Server V8.0 Fix Pack 9
8.5.5.3: WebSphere Application Server V8.5.5 Fix Pack 3
8.5.5.4: WebSphere Application Server V8.5.5 Fix Pack 4
8.0.0.10: WebSphere Application Server V8.0 Fix Pack 10
8.5.5.5: WebSphere Application Server V8.5.5 Fix Pack 5
8.5.5.6: WebSphere Application Server V8.5.5 Fix Pack 6
8.0.0.11: WebSphere Application Server V8.0 Fix Pack 11
8.5.5.7: WebSphere Application Server V8.5.5 Fix Pack 7
8.5.5.8: WebSphere Application Server V8.5.5 Fix Pack 8
8.0.0.12: WebSphere Application Server V8.0 Fix Pack 12
8.5.5.9: WebSphere Application Server V8.5.5 Fix Pack 9
8.5.5.10: WebSphere Application Server V8.5.5 Fix Pack 10
8.5.5.11: WebSphere Application Server V8.5.5 Fix Pack 11
8.0.0.13: WebSphere Application Server V8.0 Fix Pack 13
8.5.5.12: WebSphere Application Server V8.5.5 Fix Pack 12
8.0.0.14: WebSphere Application Server V8.0 Fix Pack 14
8.5.5.13: WebSphere Application Server V8.5.5 Fix Pack 13
8.0.0.15: WebSphere Application Server V8.0 Fix Pack 15
8.5.5.14: WebSphere Application Server V8.5.5 Fix Pack 14
8.5.5.15: WebSphere Application Server V8.5.5 Fix Pack 15
8.5.5.14: WebSphere Application Server V8.5.5 Fix Pack 14
8.5.5.17: WebSphere Application Server V8.5.5 Fix Pack 17
8.5.5.20: WebSphere Application Server V8.5.5.20
8.5.5.18: WebSphere Application Server V8.5.5 Fix Pack 18
8.5.5.19: WebSphere Application Server V8.5.5 Fix Pack 19
8.5.5.16: WebSphere Application Server V8.5.5 Fix Pack 16
8.5.5.21: WebSphere Application Server V8.5.5.21

Subscribe

You can track all active APARs for this component.

 

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                                      *
    ****************************************************************
    * 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

    PM62691

  • Reported component name

    WEBS APP SERV N

  • Reported component ID

    5724H8800

  • Reported release

    700

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2012-04-17

  • Closed date

    2013-08-06

  • Last modified date

    2013-10-10

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

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

    PM94415

Fix information

  • Fixed component name

    WEBS APP SERV N

  • Fixed component ID

    5724H8800

Applicable component levels

  • R800 PSY

       UP

  • 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":"7.0","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
28 April 2022