1. 数据库设置示例
我使用MySQL作为我的数据库。
从以下位置创建表EJB__TIMER__TBL
{GF_HOME}/glassfish/lib/install/databases/ejbtimer_{DB_ENGINE}.sql
DB_ENGINE = e.g MySQL:
CREATE TABLE EJB__TIMER__TBL (
`CREATIONTIMERAW` BIGINT NOT NULL,
`BLOB` BLOB,
`TIMERID` VARCHAR(255) NOT NULL,
`CONTAINERID` BIGINT NOT NULL,
`OWNERID` VARCHAR(255) NULL,
`STATE` INTEGER NOT NULL,
`PKHASHCODE` INTEGER NOT NULL,
`INTERVALDURATION` BIGINT NOT NULL,
`INITIALEXPIRATIONRAW` BIGINT NOT NULL,
`LASTEXPIRATIONRAW` BIGINT NOT NULL,
`SCHEDULE` VARCHAR(255) NULL,
`APPLICATIONID` BIGINT NOT NULL,
CONSTRAINT `PK_EJB__TIMER__TBL` PRIMARY KEY (`TIMERID`)
);
2. 服务器配置
- 启动 GlassFish 服务器管理控制台:通常
http://localhost:4848
- 在左侧导航到 [配置] > [服务器配置] > [EJB 容器]
- 然后单击顶部的 TAB [EJB 定时器服务]
- 然后填写计时器数据源:与您的JDBC资源,例如。[mysql-pu].( 注意:默认为
jdbc/__TimerPool
)
-
重新启动服务器
3. 结果
...
INFO: [TimerBeanContainer] Created TimerBeanContainer: TimerBean
INFO: EJB5181:Portable JNDI names for EJB TimerBean: [java:global/ejb-timer-service-app/TimerBean, java:global/ejb-timer-service-app/TimerBean!com.sun.ejb.containers.TimerLocal]
INFO: WEB0671: Loading application [ejb-timer-service-app] at [/ejb-timer-service-app]
INFO: EJB5109:EJB Timer Service started successfully for data source [mysql-pu]
INFO: Setting DBReadBeforeTimeout to false
INFO: ==> Restoring Timers ...
INFO: There are no EJB Timers owned by this server
INFO: <== ... Timers Restored.
...
4. 还坏了吗?计时器服务刚刚停止工作(它曾经工作过)?
因此,在充满“保存时部署”的一天之后,这发生在我身上。定时服务突然不可用。
Severe: Exception while loading the app
Severe: Undeployment failed for context /ejb-timer-service-app
Warning: Cannot deploy or load EJBTimerService: org.glassfish.deployment.common.DeploymentException: Error in linking security policy for ejb-timer-service-app -- Inconsistent Module State
在此处找到的解决方案
5. 有用的链接