Glassfish服务器上的自动EJB定时器不触发 [英] Automatic EJB Timer on Glassfish Server not triggering

查看:189
本文介绍了Glassfish服务器上的自动EJB定时器不触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在Glassfish 3.1上运行Java EAR应用程序。我在我的EJB模块中创建了一个带有单个注释定时器功能的无状态会话bean。我没有确切的代码,但看起来像这样:

  @Stateless 
public class SessionTimerBean {

public SessionTimerBean(){
System.out.println(Constructor Called);
}

@Schedule(second =* / 10,minute =*,hour =*)
public void scheduleTimer(final Timer t){
System.out.println(Timer Called);
}
}

当我启动Glassfish时,调试信息似乎表明它识别EJB定时器注释,并且bean的构造方法在启动时被调用。但是计时器方法本身似乎从来没有被触发过。



有其他人有这个问题吗?有没有其他配置我失踪了?



提前感谢

解决方案

根据规范,按照惯例执行:


定时器服务用于对长期业务
进程进行建模。计时器可以在容器崩溃,服务器关闭以及向其注册的企业bean

激活/钝化和加载/存储周期中幸存下来。这些持久的担保可以在每个定时器的基础上
被禁用。


Aksel展示了如何禁用持久保证。 glassfish服务器使用其默认数据库来持久定时器(请查看这里)。我可以想象它没有开始运行,因为计时器不起作用。使用以下命令启动它:

  asadmin start-database 


So I'm running a Java EAR application on a Glassfish 3.1. I created a stateless session bean with a single annotated timer function in my EJB Module. I don't have the exact code but it looks something like this:

@Stateless
public class SessionTimerBean {

    public SessionTimerBean(){
       System.out.println("Constructor Called");
    }

    @Schedule(second="*/10", minute="*", hour="*")
    public void scheduleTimer(final Timer t) {
       System.out.println("Timer Called");
    }
}

When I launch Glassfish the debug info seems to indicate that it recognizes the EJB timer annotations and the constructor method for the bean does get called upon launch. But the timer method itself never seems to get triggered at any point.

Has anyone else had this issue? Is there some other configuration I'm missing?

Thanks in advance.

解决方案

According to the spec, Timers are persistent by convention:

The timer service is intended for the modelling of long-lived business processes. Timers survive container crashes, server shutdown, and the activation/passivation and load/store cycles of the enterprise beans that are registered with them. These persistent guarantees can optionally be disabled on a per-timer basis.

Aksel demonstrated how persistent guarantees can be disabled. The glassfish server uses its default database for persisting its timers (take a look here). I could imagine that it was not up and running and because of that the timers did not work. Use the following command to start it:

asadmin start-database

这篇关于Glassfish服务器上的自动EJB定时器不触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆