Ошибка transaction is not active

I have this class which is dedicated to persist data in db through persistance layer of hibernate.

public class TLinkEquipementDAOImpl implements TLinkEquipementDAO {

    private static final Log log = LogFactory
            .getLog(TLinkEquipementDAOImpl.class);

    @PersistenceContext
    private EntityManagerFactory emf = PersistenceManager.getInstance()
            .getEntityManagerFactory();
    private EntityManager entityManager = emf.createEntityManager();

    private EntityTransaction tx = entityManager.getTransaction();

    public void persist(TLinkEquipement transientInstance) {
        log.debug("persisting TLinkEquipement instance");
        try {
            tx.begin();
            entityManager.persist(transientInstance);
            tx.commit();
            log.debug("persist successful");
        } catch (RuntimeException re) {
            tx.rollback();
            log.error("persist failed", re);
            throw re;
        }
    }
//Staff
}

The problem is that it does not persist data.

The stack is:

Exception in thread "main" java.lang.IllegalStateException: Transaction not active
    at org.hibernate.ejb.TransactionImpl.rollback(TransactionImpl.java:82)
    at sau.se.domain.dao.Impl.TLinkEquipementDAOImpl.persist(TLinkEquipementDAOImpl.java:47)
    at sau.se.domain.service.Impl.TLinkEquipementServiceImpl.persist(TLinkEquipementServiceImpl.java:29)
    at sau.se.extractor.InfoExtract.getAllSPData(InfoExtract.java:346)
    at sau.se.extractor.InfoExtract.main(InfoExtract.java:436)

But i have to note, that it works fine in other classes.

UPDATE:

when i make print of tx.isActive() it gives me false.

UPDATE

I tried to more get some info about the error:

I got where the problem is:

Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: sau.se.domain.model.TLinkEquipement.TEquipementsByIdEquipement2 -> sau.se.domain.model.TEquipements
    at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:376)

in fact, the table TLinkEquipement has 2 fk to the same table TEquipements, and me, i persist data of TEquipements then those of TLinkEquipement

JBoss : Transaction is not active: tx=TransactionImple < ac, BasicAction: abc status: ActionStatus.ABORTED >

 Problem

 Closing a connection for you.  Please close them yourself: org.jboss.resource.adapter.jdbc.jdk5.WrappedConnectionJDK5@6e3a0a96

2021-11-16 12:23:43,715 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] (Thread-1371) [com.arjuna.ats.arjuna.coordinator.TransactionReaper_7] — TransactionReaper::doCancellations worker Thread[Thread-1371,5,jboss] successfully canceled TX a11267b:ff8e:61915e7e:1413e57

2021-11-16 12:23:43,715 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] (Thread-1371) [com.arjuna.ats.arjuna.coordinator.BasicAction_58] — Abort of action id a11267b:ff8e:61915e7e:1413e5d invoked while multiple threads active within it.

2021-11-16 12:23:43,715 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] (Thread-1371) [com.arjuna.ats.arjuna.coordinator.CheckedAction_2] — CheckedAction::check — atomic action a11267b:ff8e:61915e7e:1413e5d aborting with 1 threads active!

2021-11-16 12:23:43,731 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] (WorkerThread#73[10.72.65.85:55546]) [com.arjuna.ats.arjuna.coordinator.BasicAction_40] — Abort called on already aborted atomic action a11267b:ff8e:61915e7e:1413e57

2021-11-16 12:23:43,809 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] (Thread-19) [com.arjuna.ats.arjuna.coordinator.TransactionReaper_18] — TransactionReaper::check timeout for TX a11267b:ff8e:61915e7e:1413e5d in state  CANCEL

2021-11-16 12:23:43,840 WARN  [org.hibernate.util.JDBCExceptionReporter] (WorkerThread#178[10.72.65.85:55540]) SQL Error: 0, SQLState: null

2021-11-16 12:23:43,840 ERROR [org.hibernate.util.JDBCExceptionReporter] (WorkerThread#178[10.72.65.85:55540]) Transaction is not active: tx=TransactionImple < ac, BasicAction: a11267b:ff8e:61915e7e:1413e5d status: ActionStatus.ABORTED >; — nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: a11267b:ff8e:61915e7e:1413e5d status: ActionStatus.ABORTED >)

Possible Solution

1: Increase the transaction timeout in transaction-jboss-beans.xml
file inside the jboss deploy folder 

<property
name=»transactionTimeout»>1800</property>

2: Increase the value of txReaperTimeout in jbossts-properties.xml
inside the jboss’s conf folder

 <property

           
name=»com.arjuna.ats.arjuna.coordinator.txReaperTimeout»
value=»240000″/>

Submitted by: Account systems Ltd. (nmx)

….
DefaultTransaction := TIBTransaction.Create(Self);
DefaultTransaction.Params.Clear;
DefaultTransaction.Params.Add(‘read’ );
DefaultTransaction.Params.Add(‘read_committed’);
DefaultTransaction.Params.Add(‘rec_version’ );
DefaultTransaction.Params.Add(‘nowait’ );
….
FModifyTransaction := TIBTransaction.Create(Self);
FModifyTransaction.Params.Clear;
FModifyTransaction.Params.Add(‘read’ );
FModifyTransaction.Params.Add(‘write’ );
FModifyTransaction.Params.Add(‘concurrency’ );
FModifyTransaction.Params.Add(‘nowait’ );
FModifyTransaction.DefaultDatabase := self;
….
procedure TNMXCustomDataSet.Save;
begin
RestoreFiltration;

if Assigned(FMasterDataSet) then FMasterDataSet.Save else
try
MF.CursorAsSQLWait;

ModifyTransaction.StartTransaction;

Apply;
MF.DB.Valid(FTableName,Num);
ModifyTransaction.Commit;
NoWaitEvent;

FOk     := true;
MF.CursorAsStored;

if Assigned(FAfterSave) then FAfterSave(self);

except
ModifyTransaction.Rollback;
FOk := false;
MF.CursorAsStored;
raise;
end;
end;

When metod CustomDataSet.Save execute, raise excption «Transaction is not active» in «ModifyTransaction.StartTransaction;» line.

In FB 2.0.3 (in test database) metod CustomDataSet.Save work correct.

sory for bad English.

I have this error on my application work:

11:01:40,453 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_58] - Abort of action id a001912:12dc:467bdf8d:2385f invoked while multiple threads active within it.
11:01:40,453 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.CheckedAction_2] - CheckedAction::check - atomic action a001912:12dc:467bdf8d:2385f aborting with 1 threads active!
11:01:40,453 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null
11:01:40,453 ERROR [JDBCExceptionReporter] Transaction is not active: tx=TransactionImple < ac, BasicAction: a001912:12dc:467bdf8d:2385f status: ActionStatus.ABORTED >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: a001912:12dc:467bdf8d:2385f status: ActionStatus.ABORTED >)
11:01:40,484 ERROR [TxInterceptorCMT] IllegalStateException while setting transaction for rollback only
java.lang.IllegalStateException: [com.arjuna.ats.internal.jta.transaction.arjunacore.inactive] [com.arjuna.ats.internal.jta.transaction.arjunacore.inactive] The transaction is not active!
 at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.setRollbackOnly(TransactionImple.java:344)
 at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:157)
 at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
 at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
 at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
 at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
 at org.jboss.ejb.plugins.CleanShutdownInterceptor.invoke(CleanShutdownInterceptor.java:278)
 at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
 at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
 at org.jboss.ejb.Container.invoke(Container.java:960)
 at sun.reflect.GeneratedMethodAccessor114.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
 at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
 at org.jboss.invocation.unified.server.UnifiedInvokerHA.invoke(UnifiedInvokerHA.java:146)
 at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:734)
 at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
 at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:383)
 at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)

Application have client-server architecture. Error appears on server side.
I use jboss-4.2.0GA+Spring+Hibernate. And on server i use -XX:+UseParallelGC option on JVM. How fix this error?

Home
> Hibernate > Transaction is not active: tx=TransactionImple < ac, BasicAction

This is an exception I was getting while trying to do some hibernate stuff.

Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
    at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
    at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1573)
    at org.hibernate.loader.Loader.doQuery(Loader.java:696)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
    at org.hibernate.loader.Loader.doList(Loader.java:2228)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
    at org.hibernate.loader.Loader.list(Loader.java:2120)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
    at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67)
    ... 97 more
Caused by: org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImple < ac, BasicAction: -53effdb8:7d1:4bb313e3:7a status: ActionStatus.ABORT_ONLY >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: -53effdb8:7d1:4bb313e3:7a status: ActionStatus.ABORT_ONLY >)
    at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:95)
    at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:46)
    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
    ... 111 more
Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: -53effdb8:7d1:4bb313e3:7a status: ActionStatus.ABORT_ONLY >
    at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:370)
    at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:496)
    at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)
    at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
    ... 113 more

It turned out that this is not a hibernate or jboss exception at all. The actual cause of this was a NullPointerException somewhere in the flow of the application. This caused the transaction to end and re-enter a loop when the transaction was not active and this was thrown. So if you ever get this exception I suggest you put some break points in your code and see where it fails. It’s likely that there is an unchecked exception thrown somewhere in your programme.

Понравилась статья? Поделить с друзьями:
  • Ошибка traceback most recent call last file
  • Ошибка tpws тойота прадо 150
  • Ошибка tpms ниссан теана l33
  • Ошибка timeout при подключении к серверу
  • Ошибка timeout error is occurred