Undeploy leads to interruption of transactions of a longer running process
jobame Apr 16, 2013 5:41 AMIn a singleton we use a timer service to start a longer running process (e.g. currently up to 2 minutes). That process uses JPA to interact with the database (CMT, using the singleton for transaction demarcation).
With JBoss when a redeployment is done while that process is running the already started transaction cannot be committed/rolledback which leads to loads of exceptions of the below form - details see below. We tried out different forms of undeployment, e.g.
- using maven with "mvn jboss-as:undeploy"
- manual undeployment via admin console
- using the cli console with "[standalone@localhost:9999 /] undeploy as24BillingEAR.ear --keep-content"
but all show the same behavior.
Questions:
- Is it possible to undeploy an application but have JBoss first make sure that the currently running transactions have been ended?
- Can it be controlled programmatically (even if I change the transaction part within the singleton to use a stateless bean with REQUIRES_NEW it is possible that at least one transaction fails; same would apply when using a message queue).
Details:
@Singleton public class StartTimer { @Schedule(second = "0", minute = "*/5", hour = "*", persistent = false) public void processItems() { // processing takes place } }
16042013 10:46:00,077 WARNUNG [AccountStateTimer.java:fetchDueSubscriptions:42] ... start processing [...] 16042013 10:46:07,248 INFO [WeldService.java:stop:89] JBAS016009: Stopping weld service for deployment myEAR.ear 16042013 10:46:07,255 INFO [PersistenceUnitServiceImpl.java:stop:94] JBAS011403: Stopping Persistence Unit Service 'myEAR.ear/myEJB.jar#SalesforcePersUnit' 16042013 10:46:07,259 ERROR [AbstractEntityManagerImpl.java:handlePersistenceException:1272] HHH000337: Unable to mark for rollback on PersistenceException: : org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.service.jta.platform.spi.JtaPlatform] at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:126) [hibernate-core-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.ejb.AbstractEntityManagerImpl.markAsRollback(AbstractEntityManagerImpl.java:1138) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.ejb.AbstractEntityManagerImpl.handlePersistenceException(AbstractEntityManagerImpl.java:1268) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1362) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1289) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final] at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:261) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final] at de.ab23.dao.salesforce.impl.SubscriptionDao.getNewSubscriptionBy(SubscriptionDao.java:131) [myEJB.jar:] at de.ab23.dsm.service.impl.NewSubscriptionService.processDebitorSubscriptions(NewSubscriptionService.java:85) [myEJB.jar:] at de.ab23.dsm.service.impl.NewSubscriptionService.computeNewSubscriptions(NewSubscriptionService.java:62) [myEJB.jar:] at de.ab23.dsm.worker.AccountStateTimer.fetchDueSubscriptions(AccountStateTimer.java:43) [myEJB.jar:] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_37]