ActionStatus.ABORT_ONLY>未处于调用缓存操作的有效状态

时间:2016-11-14 01:16:59

标签: hibernate wildfly infinispan wildfly-10

我得到以下奇怪的异常,在打电话时; Hibernate V 5.2.1中的 session.flush() 我使用容器管理的会话。

我在这里做错了什么?

    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void insertOrUpdate(T entity) {
..
crud().saveOrUpdate(entity);

}
public void saveOrUpdate(T entity) {
        Session session = null;
        try {
            session = getSession();
            session.clear();
            session.saveOrUpdate(entity);
            session.flush();  //Causes issue <-----
        }  catch (HibernateException ex) {
            log.error("Error when save or update." + entity.getCode(), ex);
        }
    }

异常

2016-11-12 00:00:02,960 ERROR [org.jboss.as.ejb3.invocation] (default task-59) WFLYEJB0034: EJB Invocation failed on component TankObservationService for method public void xx.lob2.service.autogen.TankObservationService.insertOrUpdate(xx.core.model.wetstock.analysis.TankObservation): javax.ejb.EJBTransactionRolledbackException: Transaction TransactionImple < ac, BasicAction: 0:ffffac110002:20d0e287:58255b3a:20c0f3 status: ActionStatus.ABORT_ONLY > is not in a valid state to be invoking cache operations on.
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:159)
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:256)
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:329)
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:47)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.deployment.processors.StartupAwaitInterceptor.processInvocation(StartupAwaitInterceptor.java:22)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:67)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356)
        at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:636)
        at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356)
        at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

Caused by: java.lang.IllegalStateException: Transaction TransactionImple < ac, BasicAction: 0:ffffac110002:20d0e287:58255b3a:20c0f3 status: ActionStatus.ABORT_ONLY > is not in a valid state to be invoking cache operations on.
        at org.infinispan.interceptors.TxInterceptor.enlist(TxInterceptor.java:395)
        at org.infinispan.interceptors.TxInterceptor.enlistWriteAndInvokeNext(TxInterceptor.java:358)
        at org.infinispan.interceptors.TxInterceptor.visitPutKeyValueCommand(TxInterceptor.java:221)
        at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:78)
        at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:99)
        at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:114)
        at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:83)
        at org.infinispan.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:43)
        at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:78)
        at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:335)
        at org.infinispan.cache.impl.CacheImpl.executeCommandAndCommitIfNeeded(CacheImpl.java:1672)
        at org.infinispan.cache.impl.CacheImpl.putInternal(CacheImpl.java:1121)
        at org.infinispan.cache.impl.CacheImpl.put(CacheImpl.java:1111)
        at org.infinispan.cache.impl.DecoratedCache.put(DecoratedCache.java:453)
        at org.infinispan.cache.impl.AbstractDelegatingCache.put(AbstractDelegatingCache.java:291)
        at org.hibernate.cache.infinispan.access.TxInvalidationCacheAccessDelegate.update(TxInvalidationCacheAccessDelegate.java:63)
        at org.hibernate.cache.infinispan.entity.ReadWriteAccess.update(ReadWriteAccess.java:29)
        at org.hibernate.action.internal.EntityUpdateAction.cacheUpdate(EntityUpdateAction.java:222)
        at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:196)
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:582)
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:456)
        at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
        at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
        at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1397)
        at com.cdi.crud.infra.Crud.saveOrUpdate(Crud.java:610)
        at com.cdi.crud.infra.CrudService.insertOrUpdate(CrudService.java:85)
        at xx.lob2.service.autogen.TankObservationService.insertOrUpdate(TankObservationService.java:444)
        at sun.reflect.GeneratedMethodAccessor301.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

1 个答案:

答案 0 :(得分:2)

当您调用flush()时,事务已经提交或回滚。似乎您使用容器管理的事务,您是否明确地进行了事务处理?

以前的故障可能会将事务标记为仅回滚。

另一种可能性是事务已超时(默认情况下事务会在1分钟后自动回滚),但我认为错误消息看起来不同。