设置/配置EJB定时服务的数据源 [英] Set/configure the EJB Timer Service’s DataSource
本文介绍了设置/配置EJB定时服务的数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
@Stateless
@我的应用程序使用EJB 3.1中的定时服务LocalBean
public class StatelessTimerSessionBean {
@Schedule(minute =*,second =0,dayOfMonth =*,month =*,year =*,小时=9-17,dayOfWeek =周一至周五)
public void myTimer(){
System.out.println(Timer event:+ new Date());
$ blockquote
.. set EJB定时服务的Timer DataSource设置为一个有效的JDBC资源。
来自
- 启动GlassFish服务器管理控制台:通常
http:// localhost:4848
- 在左侧导航至 [配置] > [server-config]> [EJB容器]
- 然后单击 TAB 顶部 [EJB定时服务]
- 然后用您的JDBC资源填写计时器数据源:例如。 [MySQL的普]。 ( 注意:默认为
jdbc / __ TimerPool
)
- 重新启动 / li>
3。结果
...
INFO:[TimerBeanContainer]创建TimerBeanContainer:TimerBean
INFO:EJB5181: EJB TimerBean的可移植JNDI名称:[java:global / ejb-timer-service-app / TimerBean,java:global / ejb-timer-service-app / TimerBean!com.sun.ejb.containers.TimerLocal]
INFO:WEB0671:在[/ ejb-timer-service-app]加载应用程序[ejb-timer-service-app]
INFO:EJB5109:EJB定时器服务已成功启动数据源[mysql-pu]
INFO:将DBReadBeforeTimeout设置为false
INFO:==>恢复计时器...
INFO:此服务器没有EJB计时器
INFO:< == ...定时器已恢复。
...
4。仍然破碎? TimerService刚刚停止工作(它曾经工作过)?
因此,经过一天完整的部署保存后,这发生在我身上。
严重:加载应用程序时出现异常
严重:上下文取消部署失败/ ejb-timer-service-app
警告:无法部署或加载EJBTimerService:org.glassfish.deployment.common.DeploymentException:链接ejb-timer-service-app的安全策略时出错 - 不一致的模块状态
5。有用的链接
I'm trying to use the Timer Service in EJB 3.1 in my app.
@Stateless
@LocalBean
public class StatelessTimerSessionBean {
@Schedule(minute = "*", second = "0", dayOfMonth = "*", month = "*", year = "*", hour = "9-17", dayOfWeek = "Mon-Fri")
public void myTimer() {
System.out.println("Timer event: " + new Date());
}
}
".. set the EJB Timer Service’s Timer DataSource setting to a valid JDBC resource.."
from EJB Timer Service
I cannot figure out how to configure the Timer Datasource correctly?
The error I get when deploying is:
SEVERE: Exception while invoking class org.glassfish.ejb.startup.EjbApplication start method
java.lang.RuntimeException: EJB Timer Service is not available
Running: glassfish-3.1.2.2
解决方案 1. Example Database Setup
I use MySQL for my database.
Create the table EJB__TIMER__TBL
from {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. Server Configuration
- Start your GlassFish server admin console: usually
http://localhost:4848
- On your left navigate to [Configurations] > [server-config] > [EJB Container]
- Then click the TAB up top [EJB Timer Service]
- Then fill out Timer Datasource: with your JDBC Resource eg. [mysql-pu]. ( Note: Defaults to
jdbc/__TimerPool
)
- Restart the Server
3. The Result
...
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. Still Broken? TimerService just stopped working (it used to work)?
So this happened to me after a day full of "deploy on save". The TimerService was unavailable all of a sudden.
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. Useful Links
这篇关于设置/配置EJB定时服务的数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文