Как устранить ошибку OpenJPA - попытка зафиксировать нулевое значение javax.transaction.Transaction - PullRequest
2 голосов
/ 13 марта 2012

Как устранить неполадки после ошибки openjpa.

"Попытка зафиксировать нулевое значение javax.transaction.Transaction. Некоторые серверы приложений устанавливают нулевую транзакцию в случае отката."

Я вижупохожая ошибка здесь , но комментариев не было.

Полная трассировка стека:

    [2012-03-12 02:32:29,476] ERROR {org.apache.ode.bpel.engine.BpelEngineImpl} -  Scheduled job failed; jobDetail=JobDetails( instanceId: null mexId: hqejbhcnphr7333k8shi7i processId: {http://ode/bpel/sampleprocess2}sampleProcess-1 type: INVOKE_INTERNAL channel: null correlatorId: null correlationKeySet: null retryCount: null inMem: false detailsExt: {enqueue=false}) {org.apache.ode.bpel.engine.BpelEngineImpl}
<openjpa-2.0.0-wso2v1-r52033:64539M nonfatal user error> org.apache.openjpa.persistence.InvalidStateException: Attempt to commit a null javax.transaction.Transaction.  Some application servers set the transaction to null if a rollback occurs.
    at org.apache.openjpa.kernel.BrokerImpl.setRollbackOnlyInternal(BrokerImpl.java:1595)
    at org.apache.openjpa.kernel.BrokerImpl.setRollbackOnly(BrokerImpl.java:1581)
    at org.apache.openjpa.kernel.DelegatingBroker.setRollbackOnly(DelegatingBroker.java:951)
    at org.apache.openjpa.persistence.EntityManagerImpl.setRollbackOnly(EntityManagerImpl.java:605)
    at org.apache.openjpa.persistence.PersistenceExceptions$2.translate(PersistenceExceptions.java:77)
    at org.apache.openjpa.kernel.DelegatingQuery.translate(DelegatingQuery.java:99)
    at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:536)
    at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:288)
    at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:300)
    at org.apache.ode.dao.jpa.ProcessDAOImpl.getCorrelator(ProcessDAOImpl.java:95)
    at org.apache.ode.bpel.engine.BpelRuntimeContextImpl.select(BpelRuntimeContextImpl.java:306)
    at org.apache.ode.bpel.runtime.PICK.run(PICK.java:105)
    at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.ode.jacob.vpu.JacobVPU$JacobThreadImpl.run(JacobVPU.java:451)
    at org.apache.ode.jacob.vpu.JacobVPU.execute(JacobVPU.java:139)
    at org.apache.ode.bpel.engine.BpelRuntimeContextImpl.execute(BpelRuntimeContextImpl.java:879)
    at org.apache.ode.bpel.engine.PartnerLinkMyRoleImpl.invokeNewInstance(PartnerLinkMyRoleImpl.java:205)
    at org.apache.ode.bpel.engine.BpelProcess$1.invoke(BpelProcess.java:309)
    at org.apache.ode.bpel.engine.BpelProcess.invokeProcess(BpelProcess.java:250)
    at org.apache.ode.bpel.engine.BpelProcess.invokeProcess(BpelProcess.java:305)
    at org.apache.ode.bpel.engine.BpelProcess.handleJobDetails(BpelProcess.java:458)
    at org.apache.ode.bpel.engine.BpelEngineImpl.onScheduledJob(BpelEngineImpl.java:553)
    at org.apache.ode.bpel.engine.BpelServerImpl.onScheduledJob(BpelServerImpl.java:445)
    at org.apache.ode.scheduler.simple.SimpleScheduler$RunJob$1.call(SimpleScheduler.java:537)
    at org.apache.ode.scheduler.simple.SimpleScheduler$RunJob$1.call(SimpleScheduler.java:531)
    at org.apache.ode.scheduler.simple.SimpleScheduler.execTransaction(SimpleScheduler.java:284)
    at org.apache.ode.scheduler.simple.SimpleScheduler.execTransaction(SimpleScheduler.java:239)
    at org.apache.ode.scheduler.simple.SimpleScheduler$RunJob.call(SimpleScheduler.java:531)
    at org.apache.ode.scheduler.simple.SimpleScheduler$RunJob.call(SimpleScheduler.java:515)
    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)

[2012-03-12 02:32:29,477] ERROR {org.apache.ode.scheduler.simple.SimpleScheduler} -  Error while processing a persisted job: Job hqejbhcnphr7333k8shi7j time: 2012-03-12 02:32:29 PDT transacted: true persisted: true details: JobDetails( instanceId: null mexId: hqejbhcnphr7333k8shi7i processId: {http://ode/bpel/sampleprocess2}sampleProcess-1 type: INVOKE_INTERNAL channel: null correlatorId: null correlationKeySet: null retryCount: null inMem: false detailsExt: {enqueue=false}) {org.apache.ode.scheduler.simple.SimpleScheduler}
java.lang.IllegalStateException: No transaction associated with current thread
    at org.apache.geronimo.transaction.manager.TransactionManagerImpl.rollback(TransactionManagerImpl.java:247)
    at org.apache.ode.scheduler.simple.SimpleScheduler.execTransaction(SimpleScheduler.java:297)
    at org.apache.ode.scheduler.simple.SimpleScheduler.execTransaction(SimpleScheduler.java:239)
    at org.apache.ode.scheduler.simple.SimpleScheduler$RunJob.call(SimpleScheduler.java:531)
    at org.apache.ode.scheduler.simple.SimpleScheduler$RunJob.call(SimpleScheduler.java:515)
    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)

[2012-03-12 02:32:29,683] ERROR {org.apache.ode.scheduler.simple.SimpleScheduler} -  Error while processing job, retrying in 5s {org.apache.ode.scheduler.simple.SimpleScheduler}

Свойства OpenJPA

"openjpa.TransactionMode", "managed"
"openjpa.Log", "commons"
"openjpa.ManagedRuntime", new JpaTxMgrProvider(_tm)
"openjpa.ConnectionFactory", _ds
"openjpa.ConnectionFactoryMode", "managed"
"openjpa.jdbc.TransactionIsolation", "read-committed"
"openjpa.FlushBeforeQueries", "true"

I 'Я работаю на автономном сервере, который использует Embedded Tomcat.

Я не ожидаю решения, но некоторые указатели помогут решить проблему.

Спасибо, Waruna

1 Ответ

0 голосов
/ 24 марта 2014

у меня такой же случай:

Caused by: <openjpa-2.2.2-r422266:1468616 nonfatal user error> org.apache.openjpa.persistence.InvalidStateException: Attempt to commit a null javax.transaction.Transaction.  Some application servers set the transaction to null if a rollback occurs.
at org.apache.openjpa.kernel.BrokerImpl.setRollbackOnlyInternal(BrokerImpl.java:1664)
at org.apache.openjpa.kernel.BrokerImpl.setRollbackOnly(BrokerImpl.java:1650)
... 26 more

Если ваш файл persistence.xml имеет такие свойства:

    <properties>
        <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(foreignKeys=true)"/>
    </properties>

затем openjpa генерирует все таблицы из ваших jpa-классов и таблицы OPENJPA_SEQUENCE_TABLE (ОЧЕНЬ ВАЖНО !!!).

Без свойства "openjpa.jdbc.SynchronizeMappings" таблица OPENJPA_SEQUENCE_TABLE не будет сгенерирована, и вы получите некоторые исключения в журнале openjpa, как этот:

fatal store error> org.apache.openjpa.util.StoreException: Table "OPENJPA_SEQUENCE_TABLE" not found; SQL statement:
SELECT SEQUENCE_VALUE FROM PUBLIC.OPENJPA_SEQUENCE_TABLE WHERE ID = ? FOR UPDATE [42102-174] {SELECT SEQUENCE_VALUE FROM PUBLIC.OPENJPA_SEQUENCE_TABLE WHERE ID = ? FOR UPDATE} [code=42102, state=42S02]
    at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4962)
    at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4922)
    at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:136)
    at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:110)
    at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:62)
    at org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.next(AbstractJDBCSeq.java:66)

Редактировать: попробуйте добавить эту таблицу вручную:

CREATE TABLE OPENJPA_SEQUENCE_TABLE
(
    ID TINYINT PRIMARY KEY NOT NULL,
    SEQUENCE_VALUE BIGINT
);
...