glassfish 中的 openjpa 查询缓存问题 +类转换异常形式 QueryKey
在 Glassfish 上使用 openjpa 1.2.0 及其内置 DataCache,启用查询缓存并固定一些命名查询,我们看到以下异常: org.apache.openjpa.persistence.PersistenceException:java.lang.String 无法转换为 org.apache.openjpa.datacache.QueryKey
有人有任何想法吗?
完整异常转储: [#|2011-05-01T11:43:05.728-0500|警告|sun-appserver9.1|javax.enterprise.system.core.transaction|_Threa dID=30;_ThreadName=httpSSLWorkerThread-20393-0;_RequestID=3ce3425f-cd4b-42b9-a305-570c5745add7;|JTS5054:完成后发生意外错误 org.apache.openjpa.persistence.PersistenceException:java.lang.Object 无法转换为 org.apache.openjpa.datacache.QueryKey 在org.apache.openjpa.kernel.BrokerImpl.afterCompletion(BrokerImpl.java:1870) 在 com.sun.jts.jta.SynchronizationImpl.after_completion (SynchronizationImpl.java:154) 在 com.sun.jts.CosTransactions.RegisteredSyncs.distributeAfter(RegisteredSyncs.java:210) 在com.sun.jts.CosTransactions.TopCoordinator.afterCompletion(TopCoordinator.java:2585) 在 com.sun.jts.CosTransactions.CoordinatorTerm.commit(CoordinatorTerm.java:433) 在 com.sun.jts.CosTransactions.TerminatorImpl.commit(TerminatorImpl.java:249) 在 com.sun.jts.CosTransactions.CurrentImpl.commit(CurrentImpl.java:623) 在com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:309) 在com.sun.enterprise.distributedtx.J2EETransactionManagerImpl.commit(J2EETransactionManagerImpl.java:1030) 在com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:397) 在 com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3792) 在 com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3571) 在 com.sun.ejb.containers.WebServiceInitationHandler.invoke(WebServiceInitationHandler.java:200) 在 $Proxy973.transfer(来源不明) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在 java.lang.reflect.Method.invoke(Method.java:597) 在 com.sun.enterprise.webservice.InvokerImpl.invoke(InvokerImpl.java:81) 在com.sun.enterprise.webservice.EjbInvokerImpl.invoke(EjbInvokerImpl.java:82) 在 com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146) 在 com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257) 在 com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:93) 在 com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595) 在 com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:554) 在 com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539) 在 com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436) 在 com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:106) 在 com.sun.enterprise.webservice.MonitoringPipe.process(MonitoringPipe.java:147) 在 com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115) 在 com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:595) 在 com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:554) 在 com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539) 在 com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436) 在 com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:106) 在 com.sun.xml.ws.tx.service.TxServerPipe.process(TxServerPipe.java:317) 在 com.sun.enterprise.webservice.CommonServerSecurityPipe.processRequest(CommonServerSecurityPipe.java:218) 在 com.sun.enterprise.webservice.CommonServerSecurityPipe.process(CommonServerSecurityPipe.java:129) 在 com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115) 在 com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:595) 在 com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554) 在 com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539) 在 com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436) 在 com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243) 在 com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:444) 在 com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244) 在 com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135) 在 com.sun.enterprise.webservice.Ejb3MessageDispatcher.handlePost(Ejb3MessageDispatcher.java:113) 在 com.sun.enterprise.webservice.Ejb3MessageDispatcher.invoke(Ejb3MessageDispatcher.java:87) 在com.sun.enterprise.webservice.EjbWebServiceServlet.dispatchToEjbEndpoint(EjbWebServiceServlet.java:226) 在 com.sun.enterprise.webservice.EjbWebServiceServlet.service(EjbWebServiceServlet.java:155) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:831) 在 com.sun.enterprise.web.AdHocContextValve.invoke(AdHocContextValve.java:114) 在 org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632) 在 org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577) 在org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571) 在 com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:87) 在 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206) 在 org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632) 在 org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577) 在org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571) 在 org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080) 在 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150) 在 org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632) 在 org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577) 在org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571) 在 org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080) 在 org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272) 在 com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637) 在 com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568) 在 com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813) 在 com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341) 在 com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263) 在 com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214) 在 com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265) 在 com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106) 引起原因:java.lang.ClassCastException:java.lang.Object无法转换为org.apache.openjpa.datacache.QueryKey 在 org.apache.openjpa.datacache.AbstractQueryCache.onTypesChanged(AbstractQueryCache.java:85) 在 org.apache.openjpa.datacache.DataCacheStoreManager.updateCaches(DataCacheStoreManager.java:252) 在org.apache.openjpa.datacache.DataCacheStoreManager.commit(DataCacheStoreManager.java:90) 在 org.apache.openjpa.kernel.DelegatingStoreManager.commit(DelegatingStoreManager.java:94) 在org.apache.openjpa.kernel.BrokerImpl.endStoreManagerTransaction(BrokerImpl.java:1308) 在org.apache.openjpa.kernel.BrokerImpl.endTransaction(BrokerImpl.java:2177) 在org.apache.openjpa.kernel.BrokerImpl.afterCompletion(BrokerImpl.java:1846) ... 75 更多 |#]
Using openjpa 1.2.0 with it's built-in DataCache on Glassfish, enabling query cache and pin some named queires, We see the following exception:
org.apache.openjpa.persistence.PersistenceException: java.lang.String cannot be cast to org.apache.openjpa.datacache.QueryKey
Anyone has any ideas?
Full exception dump:
[#|2011-05-01T11:43:05.728-0500|WARNING|sun-appserver9.1|javax.enterprise.system.core.transaction|_ThreadID=30;_ThreadName=httpSSLWorkerThread-20393-0;_RequestID=3ce3425f-cd4b-42b9-a305-570c5745add7;|JTS5054: Unexpected error occurred in after completion
org.apache.openjpa.persistence.PersistenceException: java.lang.Object cannot be cast to org.apache.openjpa.datacache.QueryKey
at org.apache.openjpa.kernel.BrokerImpl.afterCompletion(BrokerImpl.java:1870)
at com.sun.jts.jta.SynchronizationImpl.after_completion(SynchronizationImpl.java:154)
at com.sun.jts.CosTransactions.RegisteredSyncs.distributeAfter(RegisteredSyncs.java:210)
at com.sun.jts.CosTransactions.TopCoordinator.afterCompletion(TopCoordinator.java:2585)
at com.sun.jts.CosTransactions.CoordinatorTerm.commit(CoordinatorTerm.java:433)
at com.sun.jts.CosTransactions.TerminatorImpl.commit(TerminatorImpl.java:249)
at com.sun.jts.CosTransactions.CurrentImpl.commit(CurrentImpl.java:623)
at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:309)
at com.sun.enterprise.distributedtx.J2EETransactionManagerImpl.commit(J2EETransactionManagerImpl.java:1030)
at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:397)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3792)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3571)
at com.sun.ejb.containers.WebServiceInvocationHandler.invoke(WebServiceInvocationHandler.java:200)
at $Proxy973.transfer(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.enterprise.webservice.InvokerImpl.invoke(InvokerImpl.java:81)
at com.sun.enterprise.webservice.EjbInvokerImpl.invoke(EjbInvokerImpl.java:82)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146)
at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:93)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:554)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:106)
at com.sun.enterprise.webservice.MonitoringPipe.process(MonitoringPipe.java:147)
at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:595)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:554)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:106)
at com.sun.xml.ws.tx.service.TxServerPipe.process(TxServerPipe.java:317)
at com.sun.enterprise.webservice.CommonServerSecurityPipe.processRequest(CommonServerSecurityPipe.java:218)
at com.sun.enterprise.webservice.CommonServerSecurityPipe.process(CommonServerSecurityPipe.java:129)
at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:595)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:444)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135)
at com.sun.enterprise.webservice.Ejb3MessageDispatcher.handlePost(Ejb3MessageDispatcher.java:113)
at com.sun.enterprise.webservice.Ejb3MessageDispatcher.invoke(Ejb3MessageDispatcher.java:87)
at com.sun.enterprise.webservice.EjbWebServiceServlet.dispatchToEjbEndpoint(EjbWebServiceServlet.java:226)
at com.sun.enterprise.webservice.EjbWebServiceServlet.service(EjbWebServiceServlet.java:155)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.sun.enterprise.web.AdHocContextValve.invoke(AdHocContextValve.java:114)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:87)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
Caused by: java.lang.ClassCastException: java.lang.Object cannot be cast to org.apache.openjpa.datacache.QueryKey
at org.apache.openjpa.datacache.AbstractQueryCache.onTypesChanged(AbstractQueryCache.java:85)
at org.apache.openjpa.datacache.DataCacheStoreManager.updateCaches(DataCacheStoreManager.java:252)
at org.apache.openjpa.datacache.DataCacheStoreManager.commit(DataCacheStoreManager.java:90)
at org.apache.openjpa.kernel.DelegatingStoreManager.commit(DelegatingStoreManager.java:94)
at org.apache.openjpa.kernel.BrokerImpl.endStoreManagerTransaction(BrokerImpl.java:1308)
at org.apache.openjpa.kernel.BrokerImpl.endTransaction(BrokerImpl.java:2177)
at org.apache.openjpa.kernel.BrokerImpl.afterCompletion(BrokerImpl.java:1846)
... 75 more
|#]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一些调试后,我意识到生成的查询键为空,因为命名查询中使用的实体未启用数据缓存。
After doing some debugging, I realized that generated query key is null because entities used in a named query are not data cache enabled.