1. 示例数据库设置
我使用 MySQL 作为我的数据库。
EJB__TIMER__TBL
从创建表{GF_HOME}/glassfish/lib/install/databases/ejbtimer_{DB_ENGINE}.sql
DB_ENGINE = 例如 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
- 在您的左侧导航到[Configurations] > [server-config] > [EJB Container]
- 然后点击上方的TAB 【EJB Timer Service】
- 然后填写Timer Datasource : 使用您的 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. 还是坏了?TimerService 刚刚停止工作(它曾经工作)?
因此,在充满“保存部署”的一天之后,这发生在我身上。TimerService 突然不可用了。
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. 有用的链接