I'm setting up SmartGWTEE 2.5 application to use JPA (Glassfish + EclipseLink + Derby). --- I know JPA isn't the first option recommended, it's just what is for this particular project :) --- I think I've nearly got it all working but am getting a "javax.persistence.TransactionRequiredException", followed later by a "java.lang.IllegalStateException: Transaction is not active in the current thread." when I add data.
Do my settings look right? … Any ideas are much appreciated.
thanks!
,chris
server.properties
web.xml
persistence.xml
Log:
Do my settings look right? … Any ideas are much appreciated.
thanks!
,chris
server.properties
Code:
... jpa.emfProvider: com.isomorphic.jpa.EMFProviderCMT jpa.persistenceUnitName: ds jpa.cmt.entityManager: persistence/em jpa.cmt.transaction: persistence/tx
Code:
… <persistence-context-ref> <persistence-context-ref-name>persistence/em</persistence-context-ref-name> <persistence-unit-name>ds</persistence-unit-name> </persistence-context-ref> <resource-env-ref> <resource-env-ref-name>persistence/tx</resource-env-ref-name> <resource-env-ref-type>javax.transaction.UserTransaction</resource-env-ref-type> </resource-env-ref> …
Code:
<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="ds" transaction-type="JTA"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <jta-data-source>jdbc/signature</jta-data-source> <class>myapp.server.das.note.entities.Note</class> <properties> <property name="eclipselink.ddl-generation" value="create-tables"/> <property name="eclipselink.target-database" value="Derby"/> <property name="eclipselink.logging.level" value="FINE" /> </properties> </persistence-unit> </persistence>
Code:
[#|2011-10-18T01:04:18.615-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,615 [0(1)] DEBUG RPCManager - Request #1 (DSRequest) payload: { values:{ uid:"123abc", comments:"Hello World" }, operationConfig:{ dataSource:"NoteRecord", operationType:"add" }, componentId:"isc_DynamicForm_1", appID:"builtinApplication", operation:"NoteRecord_add", oldValues:{ }, criteria:{ } } |#] [#|2011-10-18T01:04:18.690-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,690 [0(1)] INFO IDACall - Performing 1 operation(s) |#] [#|2011-10-18T01:04:18.714-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,714 [0(1)] DEBUG AppBase - [builtinApplication.NoteRecord_add] No userTypes defined, allowing anyone access to all operations for this application |#] [#|2011-10-18T01:04:18.715-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,715 [0(1)] DEBUG AppBase - [builtinApplication.NoteRecord_add] No public zero-argument method named '_NoteRecord_add' found, performing generic datasource operation |#] [#|2011-10-18T01:04:18.716-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,716 [0(1)] DEBUG JPADataSource - [builtinApplication.NoteRecord_add] Auto-joining transactions. |#] [#|2011-10-18T01:04:18.716-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,716 [0(1)] DEBUG JPADataSource - [builtinApplication.NoteRecord_add] Creating EntityManager, starting transaction and setting it to RPCManager. |#] [#|2011-10-18T01:04:18.723-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,723 [0(1)] DEBUG DSRequest - [builtinApplication.NoteRecord_add] Clobbering existing FreeResourcesHandler of type 'com.isomorphic.jpa.JPA2DataSource' with a 'com.isomorphic.jpa.JPA2DataSource' |#] [#|2011-10-18T01:04:18.725-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,725 [0(1)] DEBUG JPADataSource - [builtinApplication.NoteRecord_add] Executing add. |#] [#|2011-10-18T01:04:18.743-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,742 [0(1)] DEBUG JPADataSource - [builtinApplication.NoteRecord_add] Marking transaction for roll back. |#] [#|2011-10-18T01:04:18.749-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,748 [0(1)] DEBUG JPADataSource - [builtinApplication.NoteRecord_add] Got exception while executing. Transaction will be rolled back. javax.persistence.TransactionRequiredException at com.sun.enterprise.container.common.impl.EntityManagerWrapper.doTxRequiredCheck(EntityManagerWrapper.java:163) at com.sun.enterprise.container.common.impl.EntityManagerWrapper.doTransactionScopedTxCheck(EntityManagerWrapper.java:145) at com.sun.enterprise.container.common.impl.EntityManagerWrapper.persist(EntityManagerWrapper.java:263) at com.isomorphic.jpa.JPADataSource.executeAdd(JPADataSource.java:714) at com.isomorphic.datasource.DataSource.execute(DataSource.java:1156) at com.isomorphic.jpa.JPADataSource.execute(JPADataSource.java:356) at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:721) at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:658) at com.isomorphic.application.AppBase.execute(AppBase.java:491) at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1714) at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:199) at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156) at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121) at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217) at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:680) |#] [#|2011-10-18T01:04:18.750-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,750 [0(1)] WARN RequestContext - dsRequest.execute() failed: javax.persistence.TransactionRequiredException at com.sun.enterprise.container.common.impl.EntityManagerWrapper.doTxRequiredCheck(EntityManagerWrapper.java:163) at com.sun.enterprise.container.common.impl.EntityManagerWrapper.doTransactionScopedTxCheck(EntityManagerWrapper.java:145) at com.sun.enterprise.container.common.impl.EntityManagerWrapper.persist(EntityManagerWrapper.java:263) at com.isomorphic.jpa.JPADataSource.executeAdd(JPADataSource.java:714) at com.isomorphic.datasource.DataSource.execute(DataSource.java:1156) at com.isomorphic.jpa.JPADataSource.execute(JPADataSource.java:356) at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:721) at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:658) at com.isomorphic.application.AppBase.execute(AppBase.java:491) at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1714) at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:199) at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156) at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121) at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217) at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:680) |#] [#|2011-10-18T01:04:18.751-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,751 [0(1)] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8 |#] [#|2011-10-18T01:04:18.753-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,753 [0(1)] DEBUG JPADataSource - Rolling back transaction for 0 queued operation(s). |#] [#|2011-10-18T01:04:18.755-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,754 [0(1)] WARN EMFProviderCMT - Unexpected exception while rolling back transaction java.lang.IllegalStateException: Transaction is not active in the current thread. at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.validateTransactionManager(JavaEETransactionManagerJTSDelegate.java:448) at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.setRollbackOnlyDistributedTransaction(JavaEETransactionManagerJTSDelegate.java:345) at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.setRollbackOnly(JavaEETransactionManagerSimplified.java:968) at com.sun.enterprise.transaction.UserTransactionImpl.setRollbackOnly(UserTransactionImpl.java:257) at com.isomorphic.jpa.EMFProviderCMT.rollbackTransaction(EMFProviderCMT.java:205) at com.isomorphic.jpa.EMF.rollbackTransaction(EMF.java:142) at com.isomorphic.jpa.JPADataSource.onFailure(JPADataSource.java:3189) at com.isomorphic.rpc.RPCManager.onFailure(RPCManager.java:1334) at com.isomorphic.rpc.RPCManager.onFailure(RPCManager.java:1234) at com.isomorphic.rpc.RPCManager.completeResponse(RPCManager.java:987) at com.isomorphic.rpc.RPCManager.send(RPCManager.java:582) at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156) at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121) at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217) at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:680) |#] [#|2011-10-18T01:04:18.756-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,756 [0(1)] DEBUG RPCManager - non-DMI response, dropExtraFields: false |#] [#|2011-10-18T01:04:18.762-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,762 [0(1)] DEBUG JPADataSource - Releasing entity manager. |#] [#|2011-10-18T01:04:18.763-0400|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-4;|=== 2011-10-18 01:04:18,763 [0(1)] INFO Compression - /MyApp/MyApp/sc/IDACall: 123 -> 113 bytes |#]
Comment