没有为id:xxx删除计时器

时间:2015-08-29 13:31:15

标签: java-ee glassfish ejb java-ee-7 glassfish-4.1

在GlassFish 4.1 / Java EE 7中的单一会话bean中使用EJB计时器,如下所示。

@Singleton
@LocalBean
@Startup
public class BackgroundJobManager {

    @PersistenceContext
    private EntityManager entityManager;

    @PostConstruct
    private void init() {
        // Do something.
    }

    @Schedule(hour = "*/1", minute = "0", second = "0", persistent = false)
    public void doHourlyJob() {
        // Do something hourly.
    }

    @Schedule(hour = "*", minute = "*/1", second = "0", persistent = false)
    private void doOnEveryMinute() {
        // Do something on every minute.
    }
}

虽然日志级别为INFO,但在(重新)部署应用程序时,服务器终端上会出现以下有点不稳定的警告。

Info:   No timers to be deleted for id: 94427432094072832
Info:   No timers to be deleted for id: 94427432094072832

这是什么意思?它是否可以避免或者容器试图严肃地警告某些事情(在这种情况下是否有任何修复)?

服务器还会在启动时记录以下行。

Info:   Portable JNDI names for EJB TimerBean: [java:global/ejb-timer-service-app/TimerBean, java:global/ejb-timer-service-app/TimerBean!org.glassfish.ejb.persistent.timer.TimerLocal]
Info:   Loading application [ejb-timer-service-app] at [/ejb-timer-service-app]
Info:   ejb.timer_service_started
Info:   ==> Restoring Timers ... 
Info:   EclipseLink, version: Eclipse Persistence Services - 2.6.0.v20150309-bf26070
Info:   /file:/C:/Program Files/glassfish-4.1/glassfish/domains/domain1/applications/ejb-timer-service-app/WEB-INF/classes/___EJB__Timer__App login successful
Info:   There are no EJB Timers owned by this server
Info:   <== ... Timers Restored.

1 个答案:

答案 0 :(得分:0)

这是目标IDE中的一个怪癖,NetBeans(是的,不是容器GlassFish本身)并且只有在NetBeans之前必须完成的IDE上关闭“保留重新部署的会话”选项时才可重现8.1。

enter image description here

(右键单击服务器,然后从子菜单中选择“属性”选项,打开上面的框架)。

在NetBeans 8.1之前,无法启用此选项。这样做会引发exception。因此,在后续重新部署中不会维护会话。因此,这些消息出现了。

NetBeans 8.1中不再存在这种情况。重新部署应用程序现在会发出以下安全消息。

Info:   keepstate options resolved to true, saving appId 95015048510636032 for application Project.
Info:   keepstate options resolved to true, saving appId 95015048510636032 for application Project.
Finer:   initialize identitymaps
Info:   Timers will not be destroyed since keepstate is true for application Project
Info:   Timers will not be destroyed since keepstate is true for application Project

持久计时器因此在重新部署期间处于活动状态。当应用程序被重新部署时,它们不会被销毁,因为它们不应该被重新部署。