11

我有一个在 jboss 6.1 上运行的应用程序,它根据已经保存在数据库中的信息在启动时定义了很多 dinamyc 计时器(例如每分钟 doSomething)。计时器是根据以下信息以编程方式创建的:

TimerConfig timerConfig = new TimerConfig();
timerConfig.setInfo(info);
timerConfig.setPersistent(false);
Timer timer = timerService.createCalendarTimer(scheduleExpression,
            timerConfig);

今天我发现创建的“每分钟”计时器不再工作了。检查昨天的日志,我发现了这个奇怪的错误(下面的完整轨迹)

Error invoking timeout for timer: [id=32b0902e-d1ee-4090-9938-98349a20340d timedObjectId=jboss.j2ee:ear=myear.ear,jar=myjar.jar,name=AppScheduler,service=EJB3 auto-timer?:false persistent?:false 
timerService=org.jboss.ejb3.timerservice.mk2.TimerServiceImpl@4036a060 initialExpiration=Thu Jan 17 00:00:00 GMT-02:00 2013 intervalDuration(in milli sec)=0 nextExpiration=Sun Jan 20 06:06:00 GMT-02:00 2013 timerState=IN_TIMEOUT: 
javax.ejb.ConcurrentAccessTimeoutException: EJB 3.1 PFD2 4.8.5.5.1 
concurrent access timeout on [advisedMethod=public void my.app.AppScheduler.process(javax.ejb.Timer), unadvisedMethod=public void my.app.AppScheduler.process(javax.ejb.Timer), metadata=null, targetObject=my.app.AppScheduler@97672ba, arguments=[Ljava.lang.Object;@3f661630]
- could not obtain lock within 5MINUTES
    at org.jboss.ejb3.concurrency.aop.interceptor.ContainerManagedConcurrencyInterceptor.invoke(ContainerManagedConcurrencyInterceptor.java:176) [:1.0.0-alpha-4]
    at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:86) [jboss-aop.jar:2.2.2.GA]
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.2.GA]
    at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47) [:1.7.21]
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.2.GA]
    at org.jboss.ejb3.tx.StatelessBMTInterceptor.handleInvocation(StatelessBMTInterceptor.java:100) [:1.0.4]
    at org.jboss.ejb3.tx.BMTInterceptor.invoke(BMTInterceptor.java:57) [:1.0.4]
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.2.GA]
    at org.jboss.ejb3.tx2.aop.NoOpInterceptor.invoke(NoOpInterceptor.java:45) [:0.0.2]
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.2.GA]
    at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) [:1.0.0.GA]
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.2.GA]
    at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41) [:1.7.21]
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.2.GA]
    at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67) [:1.7.21]
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.2.GA]
    at org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor.invoke(CurrentInvocationContextInterceptor.java:47) [:1.7.21]
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.2.GA]
    at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67) [:1.0.1]
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.2.GA]
    at org.jboss.ejb3.interceptor.EJB3TCCLInterceptor.invoke(EJB3TCCLInterceptor.java:86) [:1.7.21]
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.2.GA]
    at org.jboss.ejb3.singleton.aop.impl.AOPBasedInterceptorRegistry.intercept(AOPBasedInterceptorRegistry.java:111) [:1.0.2]
    at org.jboss.ejb3.singleton.impl.container.SingletonContainer.invoke(SingletonContainer.java:206) [:1.0.2]
    at org.jboss.ejb3.singleton.aop.impl.AOPBasedSingletonContainer.callTimeout(AOPBasedSingletonContainer.java:888) [:1.0.2]
    at org.jboss.ejb3.singleton.aop.impl.AOPBasedSingletonContainer.callTimeout(AOPBasedSingletonContainer.java:837) [:1.0.2]
    at org.jboss.ejb3.timerservice.mk2.task.CalendarTimerTask.callTimeout(CalendarTimerTask.java:84) [:1.0.0-alpha-13]
    at org.jboss.ejb3.timerservice.mk2.task.TimerTask.run(TimerTask.java:127) [:1.0.0-alpha-13]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [:1.6.0_24]
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [:1.6.0_24]
    at java.util.concurrent.FutureTask.run(FutureTask.java:138) [:1.6.0_24]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) [:1.6.0_24]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206) [:1.6.0_24]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_24]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_24]
    at java.lang.Thread.run(Thread.java:662) [:1.6.0_24]

主要问题不是单次执行的错误,而是在此问题之后计时器停止工作,并且只有在重新启动 jboss 时才会再次开始运行。有人知道防止这种行为的方法吗?异常提到了 5 分钟超时,但我看不出在哪里更改。

提前致谢。

4

2 回答 2

18

这是规范中关于此异常的内容

4.8.5.5.1 并发访问超时

无法立即获得适当锁的并发访问尝试将被阻止,直到它可以向前推进。@AccessTimeout 用于指定在超时之前应阻止访问尝试的时间量。访问超时仅适用于有资格在具有容器管理的并发的 Singleton bean 上获得并发锁的方法。如果访问尝试超时,容器将向客户端抛出 javax.ejb.ConcurrentAccessTimeoutException。@AccessTimeout 可以在业务方法或 bean 类(或超类)上指定。在类上指定的@AccessTimeout 将访问超时应用于该类的所有业务方法。如果在类和该类的业务方法上都指定了@AccessTimeout,则方法级别的注释优先。@AccessTimeout 值为 -1 表示客户端请求将无限期地阻塞,直到可以进行转发。@AccessTimeout 值为 0 表示不允许并发访问。对超时值为 0 的方法的访问尝试会导致 javax.ejb.ConcurrentAccessException

所以,我只包括访问超时来解决我的问题(5 分钟的默认时间是特定于供应商的)。

@Timeout
@AccessTimeout(value = 20, unit = TimeUnit.MINUTES)
public void process(Timer timer) {
 //code here
}
于 2013-01-30T15:30:36.007 回答
4

就我而言,问题与上次突然关机有关。我删除了下面的计时器wildfly/standalone/data/timer-service-data并再次部署。

于 2017-03-01T11:50:20.280 回答