Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2245

NotSerializableException when using a remote QueryCache and the Criteria API

    Details

      Description

      When running with a remote QueryCache and using the Criteria API the following exception will occur:

      <openjpa-2.3.0-SNAPSHOT-r422266:1367126M nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Failed to execute query "null". Check the query syntax for correctness. See nested exception for details.
      at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:872)
      at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794)
      at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
      at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:286)
      at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302)
      at org.apache.openjpa.persistence.criteria.TestRemoteQueryCacheCriteriaQuery.test(TestRemoteQueryCacheCriteriaQuery.java:42)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:600)
      at junit.framework.TestCase.runTest(TestCase.java:154)
      at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runTest(AbstractPersistenceTestCase.java:579)
      at junit.framework.TestCase.runBare(TestCase.java:127)
      at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runBare(AbstractPersistenceTestCase.java:566)
      at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runBare(AbstractPersistenceTestCase.java:542)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:118)
      at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.run(AbstractPersistenceTestCase.java:206)
      at junit.framework.TestSuite.runTest(TestSuite.java:208)
      at junit.framework.TestSuite.run(TestSuite.java:203)
      at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      Caused by: java.lang.RuntimeException: java.io.NotSerializableException: org.apache.openjpa.persistence.criteria.CriteriaQueryImpl
      at org.apache.openjpa.persistence.criteria.SerializingConcurrentQueryCache.roundtrip(SerializingConcurrentQueryCache.java:57)
      at org.apache.openjpa.persistence.criteria.SerializingConcurrentQueryCache.get(SerializingConcurrentQueryCache.java:36)
      at org.apache.openjpa.datacache.QueryCacheStoreQuery.checkCache(QueryCacheStoreQuery.java:125)
      at org.apache.openjpa.datacache.QueryCacheStoreQuery.access$000(QueryCacheStoreQuery.java:63)
      at org.apache.openjpa.datacache.QueryCacheStoreQuery$QueryCacheExecutor.executeQuery(QueryCacheStoreQuery.java:342)
      at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1005)
      at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863)
      ... 27 more
      Caused by: java.io.NotSerializableException: org.apache.openjpa.persistence.criteria.CriteriaQueryImpl
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1173)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:336)
      at org.apache.openjpa.datacache.QueryKey.writeExternal(QueryKey.java:451)
      at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1438)
      at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1407)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1167)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:336)
      at org.apache.openjpa.persistence.criteria.SerializingConcurrentQueryCache.roundtrip(SerializingConcurrentQueryCache.java:52)
      ... 33 more

        Activity

        Hide
        curtisr7 Rick Curtis added a comment -

        Rather than making CriteriaQueryImpl and all objects it references serializable, it is much simpler to hold onto the stringified version(SQL) of the CriteriaQuery in the QueryKey.

        Show
        curtisr7 Rick Curtis added a comment - Rather than making CriteriaQueryImpl and all objects it references serializable, it is much simpler to hold onto the stringified version(SQL) of the CriteriaQuery in the QueryKey.
        Hide
        curtisr7 Rick Curtis added a comment -

        Committed revision 1368438 to trunk.

        Show
        curtisr7 Rick Curtis added a comment - Committed revision 1368438 to trunk.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1756957 from Heath Thomann in branch 'openjpa/branches/2.2.x'
        [ https://svn.apache.org/r1756957 ]

        OPENJPA-2245: NotSerializableException when using a remote QueryCache and the Criteria API. Back ported to 2.2.x Rick Curtis' changes in trunk.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1756957 from Heath Thomann in branch 'openjpa/branches/2.2.x' [ https://svn.apache.org/r1756957 ] OPENJPA-2245 : NotSerializableException when using a remote QueryCache and the Criteria API. Back ported to 2.2.x Rick Curtis' changes in trunk.
        Hide
        jpaheath Heath Thomann added a comment -

        Going to commit change to 2.2.x.

        Thanks,

        Heath

        Show
        jpaheath Heath Thomann added a comment - Going to commit change to 2.2.x. Thanks, Heath

          People

          • Assignee:
            curtisr7 Rick Curtis
            Reporter:
            curtisr7 Rick Curtis
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development