2017-08-09 47 views
2

因此,我有2個xa-datsources配置在我的Wildfly 10應用程序服務器中,而我正在使用Hibernate ORM 5.2.9。而DB是Postgres 9.6獲取事務回滾到另一個線程異常

在我的應用程序中,我有一個EJB,它有2個嵌套for循環,我必須在嵌套循環的每次迭代中從表中讀取數據。但一段時間後,我得到這個異常

javax.ejb.EJBTransactionRolledbackException:org.hibernate.HibernateException:事務回滾在不同的線程!

我不明白爲什麼會發生這種情況。我有一個小的概念驗證應用程序,它使用JDBC連接到數據庫,並且一切正常。

EDIT 這是異常後的堆棧跟蹤我提到拋出:

12:39:07319 WARN [com.arjuna.ats.arjuna](默認任務-7) ARJUNA012077:中止調用已中止的原子動作 0:ffffac280184:2edc54df:598adfb2:27f 12:39:07,320錯誤[org.jboss.as.ejb3.invocation](默認任務-7)WFLYEJB0034:組件上的EJB調用失敗 ejb/calculationResource for method public void com.actuariado.smartsolve.services.api.calculation.Calcul ationResource.calculateFinancial(org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput) 拋出com.actuariado.smartsolve.exceptions.AppException: javax.ejb.EJBTransactionRolledbackException:交易在org.jboss.as.ejb3回滾 。在org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx( CMTTxInterceptor.java:279) at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:327) at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext的.java:340) 在org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) 在org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在有機.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) 在org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory $ 1.processInvocation(ShutDownInterceptorFactory.java:64) 在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) 在org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54) 在org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64) 在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.in vocation.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) 在org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java: 61) at org.jboss.as.ee.component.ViewService $ View.invoke(ViewService.java:198) at org.jboss.as.ee.component.ViewDescription $ 1.processInvocation(ViewDescription.java:185) 在org.jboss.invocatio n.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java: 73) 在com.actuariado.smartsolve.services.api.calculation.CalculationResource $$$ view200.calculateFinancial(未知 源) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本機方法) 在sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.jboss.resteasy.core .MethodInjectorImpl。調用(MethodInjectorImpl.java:139) 在org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295) 在org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249) 在org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:402) at org.jboss.resteasy.core.SynchronousDispatcher。調用(SynchronousDispatcher.java:209) at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service( HttpServletDispatcher.java:56) at org.jboss。 resiasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at io.undertow.servlet.handlers.ServletHandler.handleRequest( ServletHandler.java:85) 在io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) 在io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) 在org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers。安全。SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) 在io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) 在io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java: 43) 在io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) 在io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) 在io.undertow。 security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthe nticatedSessionHandler.java:77) 在io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) 在io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) 在IO。在io.undertow.server.handlers上的org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) 。 PredicateHandler.handleRequest(PredicateHandler.java:43) 在io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 在io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler的.java:292) 在io.undertow.servlet.handlers.ServletInitialHandler.access $ 100(ServletInitialHandler.java:81) 在io.undertow.servlet.handlers.ServletInitialHandler $ 2.call(ServletInitialHandler.java:138) 在IO .undertow.servlet.handlers.ServletInitialHandler $ 2.call(ServletInitialHandler.java:135) 在io.undertow.servlet.core.ServletRequestContextThreadSetupAction $ 1.call(ServletRequestContextThreadSetupAction.java:48) 在io.undertow.servlet.core.ContextClassLoaderSetupAction $ 1.call(ContextClassLoaderSetupAction.java:43) 在io.undertow.servlet.api.LegacyThreadSetupActionWrapper $ 1.call(LegacyThreadSetupActionWrapper.java:44) 在io.undertow.servlet.api.LegacyThreadSetupActionWrapper $ 1.call(LegacyThreadSetupActionWrapper.java: 44) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper $ 1.call(LegacyThreadSetupActionWrapper.java:44) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper $ 1.call(LegacyThreadSetupActionWrapper.java:44) at io.undertow.servlet。 api.LegacyThreadSetupActionWrapper在io.undertow.servlet.api.LegacyThreadSetupActionWrapper $ 1.call(LegacyThreadSetupActionWrapper.java:44) $ 1.call(LegacyThreadSetupActionWrapper.java:44) 在io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler。 Java的:272) 在io.undertow.servlet.handlers.ServletInitialHandler.access $ 000(ServletInitialHandler.java:81) 在io.undertow.servlet.handlers.ServletInitialHandler $ 1.handleRequest(ServletInitialHandler.java:104) 在IO。 undertow.server.Conn ectors.executeRootHandler(Connectors.java:202) at io.undertow.server.HttpServerExchange $ 1.run(HttpServerExchange.java:805) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java .util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) 導致:javax.transaction.RollbackException:WFLYEJB0447:Transaction'TransactionImple < ac ,BasicAction: 0:ffffac280184:2edc54df:598adfb2:27F狀態:ActionStatus.ABORTED>」 已經處於org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:98) 回滾 .. 。88更多

+0

您對此有更多相關信息嗎?你確定你的交易沒有實際回滾嗎? –

+0

M. Prokhorov - 我已經編輯了這個問題以包含堆棧跟蹤。希望它有助於給你更多的信息。謝謝!! – GoAlves

+0

是否有可能在此事務中對此容器執行遠程調用並ejb? – aschoerk

回答

2

所以我想我想清楚發生了什麼。 看起來,當我的EJB方法被調用時,Container創建一個全局JTA事務,或者類似的事情,它的超時時間爲5分鐘(默認爲Wildfly)。 由於我的業務邏輯(嵌套循環)處理的時間超過了這個時間,事務超時並在我嘗試再次訪問數據庫時拋出異常。

相關問題