IBM Support

PI50694: CLASSCASTEXCETPION IS THROWN IN JPA WHEN QUERYCACHE IS ENABLED.

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • When query cache is enabled, under high load, the caching
    process did not handle correctly and intermittently threw
    ClassCastException. Example:
    java.lang.ClassCastException: java.lang.String incompatible
    with java.lang.Integer
    at org.apache.openjpa.jdbc.kernel.
    PreparedSQLStoreQuery$PreparedSQLExecutor.toParameterArray
    (PreparedSQLStoreQuery.java:160)
    at
    org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:
    857)
    

Local fix

  • N/A
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server V8.0.0, V8.5.0, and V8.5.5           *
    *                  who make use of OpenJPA's QuerySQLCache.    *
    ****************************************************************
    * PROBLEM DESCRIPTION: Sporadic ClassCastException occurs      *
    *                      under heavy load when OpenJPA's         *
    *                      QuerySQLCache is enabled.               *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    When OpenJPA's QuerySQLCache is enabled, there exists the
    potential for the following ClassCastException to occur
    sporadically:
    java.lang.ClassCastException: java.lang.String
    incompatible with java.lang.Integer
    at
    org.apache.openjpa.jdbc.kernel.PreparedSQLStoreQuery$PreparedSQL
    Executor.toParameterArray(PreparedSQLStoreQuery.java:160)
    at
    org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:857)
    ... 23 more
    This exception can occur when two or more threads attempt to
    run the same query at the same time, using query
    parameters.  For example, take this query:
    q = em.createQuery("select o from MyEntity o where
    upper(o.comment) like :mrn");
    q.setParameter("mrn", "test");
    q.getResultList();
    When this query is run, an entry is created for this query in
    OpenJPA's QuerySQLCache.  If many threads run this same exact
    query at the same exact time, there is the potential for two
    or more threads to attempt to initialize the cached query. In
    most cases the cached query is only initialized once by one
    thread.  There exists a race condition where by the cached
    query could be initialized more than once.  This sets into
    motion a scenario which can cause a ClassCastException when
    the cached query is run. The window or time in which this can
    occur is very narrow and complicated (many things have to
    aline perfectly).  The details are beyond the scope of this
    APAR.  However, suffice it to say that in the absence of this
    fix, the issue can be worked around by disabling the OpenJPA
    QuerySQLCache, as described in the OpenJPA documentation.
    

Problem conclusion

  • With this fix, code has been added to OpenJPA to ensure that a
    query is initialized and cached by only one thread. In other
    words, code has been added to properly synchronize the code
    path which caused the ClassCastException.
    
    The fix for this APAR is currently targeted for
    inclusion in Service Levels (Fix Packs) 8.0.0.12 and 8.5.5.9
    of WebSphere Application Server versions 8.0.0 and 8.5.5.
    
    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

    PI50694

  • Reported component name

    WEBS APP SERV N

  • Reported component ID

    5724H8800

  • Reported release

    800

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2015-10-15

  • Closed date

    2015-10-27

  • Last modified date

    2015-10-30

  • 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

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

Document Information

Modified date:
28 April 2022