我正在尝试在我的应用程序中使用EJB 3.1中的Timer Service。
@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());
}
}
“..将EJB Timer Service的Timer DataSource设置设置为有效的JDBC资源..”
我无法弄清楚如何正确配置Timer Datasource?
部署时遇到的错误是:
SEVERE: Exception while invoking class org.glassfish.ejb.startup.EjbApplication start method
java.lang.RuntimeException: EJB Timer Service is not available
跑步:glassfish-3.1.2.2
答案 0 :(得分:28)
我使用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`)
);
http://localhost:4848
jdbc/__TimerPool
)...
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.
...
所以在经过一整天的“部署保存”之后发生了这件事。 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
<强> Solution Found Here 强>
答案 1 :(得分:0)
在JBoss / WildFly中,您可以按照以下说明操作:
Mastertheboss.com: Creating clustered EJB 3 Timers
发布时间:2015年3月8日
答案 2 :(得分:-3)
听起来像glassfish-3.1.2.2不支持EJB3,尝试使用jboss 7.
http://docs.oracle.com/cd/E26576_01/doc.312/e24939/release-notes.htm