Khalid Abu El-Soud
Khalid Abu El-Soud

Reputation: 119

@Schedule timer cause server systemException

I've a ticker method in a singleton bean that tick every minute using the following @Schdule annotation:

@Schedule(minute = "*/1", hour = "*", persistent = false)
public void tick() {
            for (ScheduledTask scheduledTask : scheduledTasks) {
                    logger.info("Start Task [" + scheduledTask.toString() + "]");
                    taskHandler.handleScheduledTask(scheduledTask);
                }
            }

where taskHandler is another singletone bean and the following is handleScheduledTask method:

@Override
@Asynchronous
public void handleScheduledTask(ScheduledTask task) {
         .
         .
         .
 // handle the scheduled task ....
         .

}

However, sometimes the tick method may called after 2 minutes. In this case, the following error arise in server log and tick method isn't called anymore

Exception occurred during commit of transaction Name=[EJB com.edafa.scheduler.Scheduler.tick()],
Xid=BEA1-4A8475B5C0D922F29728(1717681887), Status=Rolled back.

[Reason=javax.transaction.SystemException: Timed out while in 'Logging' state],
numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=93,seconds left=30,
XAServerResourceInfo[WLStore_web2sms_domain__WLS_Web2SMS-Core_mServer]=(
ServerResourceInfo[WLStore_web2sms_domain__WLS_Web2SMS-Core_mServer]=
(state=rolledback,assigned=Web2SMS-Core_mServer),
xar=WLStore_web2sms_domain__WLS_Web2SMS-Core_mServer1769014156,
re-Registered = false),
XAServerResourceInfo[Web2SMS-DB_web2sms_domain]=(
ServerResourceInfo[Web2SMS-DB_web2sms_domain]=(state=rolledback,assigned=Web2SMS-Core_mServer),
xar=weblogic.jdbc.wrapper.JTSEmulateXAResourceImpl@4d91c7c5,re-Registered = false),
SCInfo[web2sms_domain+Web2SMS-Core_mServer]=(state=rolledback),
properties=({weblogic.jdbc.remote.Web2SMS-DB=t3://172.23.250.74:3574,
weblogic.transaction.name=[EJB com.edafa.scheduler.Scheduler.tick()]}),
OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(
CoordinatorURL=Web2SMS-Core_mServer+172.23.250.74:3574+web2sms_domain+t3+,
XAResources={
    WSATGatewayRM_Web2SMS-Core_mServer_web2sms_domain,
    WLStore_web2sms_domain__WLS_Web2SMS-Core_mServer,
    Web2SMS-DB_web2sms_domain, Web2SMS-SMSGW-DB_web2sms_domain, ALARMS_DB_web2sms_domain
    },
NonXAResources={})],
CoordinatorURL=Web2SMS-Core_mServer+172.23.250.74:3574+web2sms_domain+t3+):
 weblogic.transaction.RollbackException: Timed out while in 'Logging' state
    at weblogic.transaction.internal.TransactionImpl.throwRollbackException(TransactionImpl.java:1878)
    at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:359)
    at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:250)
    at weblogic.ejb.container.internal.BaseLocalObject.postInvoke1(BaseLocalObject.java:336)
    at weblogic.ejb.container.internal.BaseLocalObject.postInvoke(BaseLocalObject.java:436)
    at weblogic.ejb.container.internal.TimerDrivenLocalObject.postInvoke(TimerDrivenLocalObject.java:58)
    at weblogic.ejb.container.timer.TimerImpl.timerExpired(TimerImpl.java:517)
    at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:304)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:550)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)
Caused by: javax.transaction.SystemException: Timed out while in 'Logging' state
    at weblogic.transaction.internal.ServerTransactionImpl.wakeUp(ServerTransactionImpl.java:1842)
    at weblogic.transaction.internal.ServerTransactionManagerImpl.processTimedOutTransactions(ServerTransactionManagerImpl.java:1690)
    at org.glassfish.transaction.TransactionManagerImplCommon.wakeUp(TransactionManagerImplCommon.java:1159)
    at weblogic.transaction.internal.ServerTransactionManagerImpl.wakeUp(ServerTransactionManagerImpl.java:1603)
    at weblogic.transaction.internal.WLSTimer.timerExpired(WLSTimer.java:20)
    ... 4 more

.>

Upvotes: 1

Views: 551

Answers (1)

Khalid Abu El-Soud
Khalid Abu El-Soud

Reputation: 119

I've worked around this problem by persist the Scheduler timer:

@Schedule(minute = "*/1", hour = "*", persistent = true)
public void tick() {
            for (ScheduledTask scheduledTask : scheduledTasks) {
                    logger.info("Start Task [" + scheduledTask.toString() + "]");
                    taskHandler.handleScheduledTask(scheduledTask);
                }
            }

Until now this solve the problem and the tick method execute every minute

Upvotes: 1

Related Questions