Reputation: 29
I have a scheduler object to do some errands. It looks like this
@Singleton
public class BackgroundScheduler
{
@EJB(beanName = "myPersistenceService")
private PersistenceService dbService; //persistence object to do some db inserts
//runs every 30 minutes
@Schedule(hour="*", minute="*/30", second="0", persistent=false)
public void BackgroundJob()
{
logger.debug("Waking up to do to chores");
DoChores();
}
private void DoChores()
{
entityObj entity;
//do some stuff here
doStuff();
//write to db
dbService.writeStuff(entity);
}
}
This works fine as long as doStuff() is done in 5 minutes. When doStuff() takes more than that, I get an exception at dbService.writeStuff(entity)
[9/24/19 20:35:09:993 EDT] 000000b6 BusinessExcep E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "writeStuff" on bean "BeanId(MYAPPEJB.jar#myPersistenceService, null)". Exception data: javax.persistence.TransactionRequiredException: No active transaction for PuId=MYAPPEJB.jar#APPCMN
at com.ibm.ws.jpa.management.JPATxEntityManager.getEMInvocationInfo(JPATxEntityManager.java:233)
at com.ibm.ws.jpa.management.JPATxEntityManager.getEMInvocationInfo(JPATxEntityManager.java:191)
at com.ibm.ws.jpa.management.JPAEntityManager.persist(JPAEntityManager.java:143)
I tried @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) on both (BackgroundScheduler and myPersistenceService). I have set "Total Transaction lifetime timeout" (Application servers<>transaction service) to 0. I also tried setting connection pool timeout to 0.
I am out of ideas as to which timeout settings is causing this.
Any help would be appreciated. Thanks.
Upvotes: 1
Views: 192
Reputation: 3484
When you set "total transaction lifetime timeout" to 0, it then defers to the "maximum transaction timeout" which has default of 300 seconds, or 5 minutes. Refer to this documentation. Try increasing this value.
Upvotes: 1