Confusing conflicts between OpenJPA and Postgresql

Started by Vitoabout 12 years ago3 messagesgeneral
Jump to latest
#1Vito
testforvln@163.com

Hi all,
I'm recently doing some research with Apache ODE engine. I use Postgresql as its external database, openjpa as its ORM solution and bitronix as its transaction manager. The ODE workflow engine starts without any problem. But when I deploy process definition files into the engine, the exception came out. I paste the error content at the end of this email.
I looked through the source code of org.apache.openjpa.lib.jdbc.DecoratingDataSource, and found that openjpa is almost definitely to meant to invoke the function of reseting transaction isolation level, which would be catched by Postgresql and return with an exception.
Does that mean openjpa works poorly with Postgresql? Or who can tell me how to solve this problem.
The error content is below:
17:32:05,155 ERROR [ProcessStoreImpl] Error persisting deployment record for {http://sample.bpel.org/bpel/sample}longFlow-1; process will not be available after restart!
<openjpa-1.2.1-r752877:753278 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: Cannot change transaction isolation level in the middle of a transaction
at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4232)
at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4197)
at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88)
at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.connect(JDBCStoreManager.java:930)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.getConnection(JDBCStoreManager.java:230)
at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:371)
at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:339)
at org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.execute(LogicalUnion.java:420)
at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:230)
at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:220)
at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:206)
at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.open(SelectResultObjectProvider.java:94)
at org.apache.openjpa.lib.rop.WindowResultList.<init>(WindowResultList.java:57)
at org.apache.openjpa.jdbc.kernel.JDBCFetchConfigurationImpl.newResultList(JDBCFetchConfigurationImpl.java:235)
at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1228)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:990)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:771)
at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:517)
at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:255)
at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294)
at org.apache.ode.store.jpa.ConfStoreConnectionJpa.setVersion(ConfStoreConnectionJpa.java:76)
at org.apache.ode.store.ProcessStoreImpl$2.call(ProcessStoreImpl.java:294)
at org.apache.ode.store.ProcessStoreImpl$2.call(ProcessStoreImpl.java:264)
at org.apache.ode.store.ProcessStoreImpl$Callable.call(ProcessStoreImpl.java:793)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.postgresql.util.PSQLException: Cannot change transaction isolation level in the middle of a transaction
at org.postgresql.jdbc2.AbstractJdbc2Connection.setTransactionIsolation(AbstractJdbc2Connection.java:944)
at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at bitronix.tm.resource.jdbc.BaseProxyHandlerClass.invoke(BaseProxyHandlerClass.java:64)
at $Proxy5.setTransactionIsolation(Unknown Source)
at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at bitronix.tm.resource.jdbc.BaseProxyHandlerClass.invoke(BaseProxyHandlerClass.java:64)
at $Proxy7.setTransactionIsolation(Unknown Source)
at org.apache.openjpa.lib.jdbc.DelegatingConnection.setTransactionIsolation(DelegatingConnection.java:257)
at org.apache.openjpa.lib.jdbc.ConfiguringConnectionDecorator.decorate(ConfiguringConnectionDecorator.java:95)
at org.apache.openjpa.lib.jdbc.DecoratingDataSource.decorate(DecoratingDataSource.java:100)
at org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection(DecoratingDataSource.java:88)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.connectInternal(JDBCStoreManager.java:941)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.connect(JDBCStoreManager.java:926)
... 27 more
17:32:05,163 ERROR [ProcessStoreImpl] DbError
java.lang.RuntimeException: java.lang.IllegalStateException: no transaction started on this thread
at org.apache.ode.store.jpa.DbConfStoreConnectionFactory.rollbackTransaction(DbConfStoreConnectionFactory.java:96)
at org.apache.ode.store.ProcessStoreImpl$Callable.call(ProcessStoreImpl.java:800)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalStateException: no transaction started on this thread
at bitronix.tm.BitronixTransactionManager.rollback(BitronixTransactionManager.java:150)
at org.apache.ode.store.jpa.DbConfStoreConnectionFactory.rollbackTransaction(DbConfStoreConnectionFactory.java:94)
... 6 more
17:32:05,163 ERROR [DeploymentPoller] Deployment of LongFlow failed, aborting for now.
org.apache.ode.bpel.iapi.ContextException: DbError
at org.apache.ode.store.ProcessStoreImpl.exec(ProcessStoreImpl.java:618)
at org.apache.ode.store.ProcessStoreImpl.deploy(ProcessStoreImpl.java:264)
at org.apache.ode.store.ProcessStoreImpl.deploy(ProcessStoreImpl.java:172)
at org.apache.ode.axis2.deploy.DeploymentPoller.check(DeploymentPoller.java:160)
at org.apache.ode.axis2.deploy.DeploymentPoller.access$300(DeploymentPoller.java:60)
at org.apache.ode.axis2.deploy.DeploymentPoller$PollingThread.run(DeploymentPoller.java:251)
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: bitronix.tm.internal.BitronixRollbackException: RuntimeException thrown during beforeCompletion cycle caused transaction rollback
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
at java.util.concurrent.FutureTask.get(FutureTask.java:83)
at org.apache.ode.store.ProcessStoreImpl.exec(ProcessStoreImpl.java:616)
... 5 more
Caused by: java.lang.RuntimeException: bitronix.tm.internal.BitronixRollbackException: RuntimeException thrown during beforeCompletion cycle caused transaction rollback
at org.apache.ode.store.jpa.DbConfStoreConnectionFactory.commitTransaction(DbConfStoreConnectionFactory.java:87)
at org.apache.ode.store.ProcessStoreImpl$Callable.call(ProcessStoreImpl.java:794)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: bitronix.tm.internal.BitronixRollbackException: RuntimeException thrown during beforeCompletion cycle caused transaction rollback
at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:241)
at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:143)
at org.apache.ode.store.jpa.DbConfStoreConnectionFactory.commitTransaction(DbConfStoreConnectionFactory.java:85)
... 6 more
Caused by: <openjpa-1.2.1-r752877:753278 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: Cannot change transaction isolation level in the middle of a transaction
at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4232)
at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4197)
at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88)
at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.connect(JDBCStoreManager.java:930)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.retainConnection(JDBCStoreManager.java:216)
at org.apache.openjpa.kernel.DelegatingStoreManager.retainConnection(DelegatingStoreManager.java:163)
at org.apache.openjpa.kernel.BrokerImpl.retainConnection(BrokerImpl.java:3710)
at org.apache.openjpa.kernel.BrokerImpl.beginStoreManagerTransaction(BrokerImpl.java:1283)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1968)
at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1908)
at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1826)
at bitronix.tm.BitronixTransaction.fireBeforeCompletionEvent(BitronixTransaction.java:532)
at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:235)
... 8 more
Caused by: org.postgresql.util.PSQLException: Cannot change transaction isolation level in the middle of a transaction
at org.postgresql.jdbc2.AbstractJdbc2Connection.setTransactionIsolation(AbstractJdbc2Connection.java:944)
at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at bitronix.tm.resource.jdbc.BaseProxyHandlerClass.invoke(BaseProxyHandlerClass.java:64)
at $Proxy5.setTransactionIsolation(Unknown Source)
at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at bitronix.tm.resource.jdbc.BaseProxyHandlerClass.invoke(BaseProxyHandlerClass.java:64)
at $Proxy7.setTransactionIsolation(Unknown Source)
at org.apache.openjpa.lib.jdbc.DelegatingConnection.setTransactionIsolation(DelegatingConnection.java:257)
at org.apache.openjpa.lib.jdbc.ConfiguringConnectionDecorator.decorate(ConfiguringConnectionDecorator.java:95)
at org.apache.openjpa.lib.jdbc.DecoratingDataSource.decorate(DecoratingDataSource.java:100)
at org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection(DecoratingDataSource.java:88)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.connectInternal(JDBCStoreManager.java:941)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.connect(JDBCStoreManager.java:926)
... 17 more

Regards,
Vito

#2Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Vito (#1)
Re: Confusing conflicts between OpenJPA and Postgresql

On 03/24/2014 07:05 AM, Vito wrote:

Hi all,
I'm recently doing some research with Apache ODE engine. I use
Postgresql as its external database, openjpa as its ORM solution and
bitronix as its transaction manager. The ODE workflow engine starts
without any problem. But when I deploy process definition files into the
engine, the exception came out. I paste the error content at the end of
this email.
I looked through the source code of
org.apache.openjpa.lib.jdbc.DecoratingDataSource, and found that openjpa
is almost definitely to meant to invoke the function of reseting
transaction isolation level, which would be catched by Postgresql and
return with an exception.
Does that mean openjpa works poorly with Postgresql? Or who can tell me
how to solve this problem.

Well it seems supported and what you report is not a known issue:

http://ci.apache.org/projects/openjpa/2.2.x/docbook/manual/main.html

A quick scan through the documentation showed a lot of different
transaction management going on. Seems a answer would probably be found
faster on the openjpa list:

http://openjpa.208410.n2.nabble.com/OpenJPA-Users-f208411.html

Regards,
Vito

--
Adrian Klaver
adrian.klaver@aklaver.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Vito (#1)
Re: Confusing conflicts between OpenJPA and Postgresql

Vito wrote:

I'm recently doing some research with Apache ODE engine. I use Postgresql as its external database,
openjpa as its ORM solution and bitronix as its transaction manager. The ODE workflow engine starts
without any problem. But when I deploy process definition files into the engine, the exception came
out. I paste the error content at the end of this email.
I looked through the source code of org.apache.openjpa.lib.jdbc.DecoratingDataSource, and found that
openjpa is almost definitely to meant to invoke the function of reseting transaction isolation level,
which would be catched by Postgresql and return with an exception.
Does that mean openjpa works poorly with Postgresql? Or who can tell me how to solve this problem.

The error content is below:

org.apache.openjpa.persistence.PersistenceException: Cannot change transaction isolation level in the
middle of a transaction

Caused by: org.postgresql.util.PSQLException: Cannot change transaction isolation level in the middle
of a transaction

That makes sense, doesn't it?
I don't think there is any database that would allow to change the isolation level
in the middle of a transaction.

I tested with Oracle:

SELECT ....

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
ERROR at line 1:
ORA-01453: SET TRANSACTION must be first statement of transaction

I think you will have to make sure that the SET TRANSACTION ISOLATION LEVEL
statement is the first statement issued in the transaction.

Yours,
Laurenz Albe

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general