我已经使用设置将 Ehcache 连接到我的 JTA 事务管理器(由 Atomikos 提供)中cacheConfiguration.setTransactionalMode("xa");
,并且在我的应用程序启动大约 15 秒后收到以下错误:
Caused by: net.sf.ehcache.transaction.TransactionTimeoutException: transaction [0] timed out
at net.sf.ehcache.transaction.local.LocalTransactionStore.assertNotTimedOut(LocalTransactionStore.java:108) ~[ehcache-2.9.0.jar:2.9.0]
at net.sf.ehcache.transaction.local.LocalTransactionStore.remove(LocalTransactionStore.java:391) ~[ehcache-2.9.0.jar:2.9.0]
at net.sf.ehcache.transaction.local.JtaLocalTransactionStore.remove(JtaLocalTransactionStore.java:375) ~[ehcache-2.9.0.jar:2.9.0]
at net.sf.ehcache.store.AbstractCopyingCacheStore.remove(AbstractCopyingCacheStore.java:110) ~[ehcache-2.9.0.jar:2.9.0]
at net.sf.ehcache.store.TxCopyingCacheStore.remove(TxCopyingCacheStore.java:33) ~[ehcache-2.9.0.jar:2.9.0]
at net.sf.ehcache.Cache.removeInternal(Cache.java:2401) ~[ehcache-2.9.0.jar:2.9.0]
at net.sf.ehcache.Cache.remove(Cache.java:2306) ~[ehcache-2.9.0.jar:2.9.0]
at net.sf.ehcache.Cache.remove(Cache.java:2224) ~[ehcache-2.9.0.jar:2.9.0]
当我的应用程序第一次启动时,它会在单个事务中执行一些初始设置,大约需要 60 秒才能完成。因此,我需要将 15 秒超时增加为更大的值,但找不到控制的位置。从查看 Ehcache 文档看来,这应该由 JTA 控制,但我已经为 UserTransaction 和 TransactionManager 设置了默认超时:
@Bean
public UserTransaction userTransaction() throws SystemException {
UserTransactionImp uti = new UserTransactionImp();
uti.setTransactionTimeout(120000);
return uti;
}
@Bean(initMethod = "init", destroyMethod = "close")
public TransactionManager transactionManager() throws SystemException {
UserTransactionManager utm = new UserTransactionManager();
utm.setForceShutdown(false);
utm.setTransactionTimeout(120000);
return utm;
}
任何指针将不胜感激。