Asynchronous thread problem
handsomeli Apr 16, 2009 4:11 AMI meet a thread problem:
I have a data processing management page.When user press the button, one data process begins.
The process takes more than 10 minutes,but when it runs for about 5 minutes, an exception throws:
2009-04-16 15:41:39,928 INFO [org.jboss.seam.async.QuartzDispatcher] In the scheduleInvocation() 2009-04-16 15:41:39,928 INFO [org.jboss.seam.async.QuartzDispatcher] In the scheduleWithQuartzService() 2009-04-16 15:41:39,932 INFO [org.jboss.seam.async.QuartzDispatcher] End executing Quartz job 2009-04-16 15:41:39,940 INFO [org.jboss.seam.async.QuartzDispatcher] Start executing Quartz job ... DOING THE DATA PROCESSING ..... 2009-04-16 15:47:40,099 WARN [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_58] - Abort of action id 7f000001:8977:49e6d1af:13c invoked while multiple threads active within it. 2009-04-16 15:47:40,099 WARN [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.CheckedAction_2] - CheckedAction::check - atomic action 7f000001:8977:49e6d1af:13c aborting with 1 threads active! 18:11:30,132 ERROR [TxPolicy] 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)
These are my code segments,from the html to java:
1.
<h:commandButton action="#{permeabilitystatList.permeabilityWeekCollect}" value="OK"/>
2. PermeabilityStatListBean
@Stateful @Scope(ScopeType.SESSION) @Name("permeabilitystatList") public class PermeabilityStatListBean implements PermeabilityStatList { @In(required=false) PermeabilityWeekCollect permeabilityWeekCollectThread; .... public void permeabilityWeekCollect() { .... permeabilityWeekCollectThread.permeabilityWeekCollect("",branchObject, weekscope); //RUN IN A THREAD .... }
3.
@Stateless @Name("permeabilityWeekCollectThread") @AutoCreate public class PermeabilityWeekCollectThread implements PermeabilityWeekCollect{ @PersistenceContext EntityManager em; .... @Asynchronous public void permeabilityWeekCollect(String centerName,Branch branch, String weekscope){ ... // RUN FOR MORE THAN 10 MINUTES!! em.persist(....); em.flush(); em.clear(); } }
According to the exception information, I think it is the closing state of permeabilitystatList which is the parent thread of permeabilityWeekCollectThread that make permeabilityWeekCollectThread lose context.
What should I do ??
Thank you very much!!!