如何在Wildfly AS 8中为数据源实现EJB计时器服务

时间:2015-03-27 11:14:35

标签: timer persistence ejb-3.1 wildfly-8

我正在将EAR应用程序从JBoss AS 6迁移到Wildfly AS 8.2.0。在做的时候,我担心在Wildfly AS中为EJB timer service中定义的数据源TestSybaseDB实施standalone-full-ha.xml

以下是与JBoss AS 6相关的文件,与数据源TestSybaseDB的EJB3计时器服务实现相关。在JBoss 6 AS的下面文件中,定义了数据源名称,我相信这些更改足以在JBoss 6 AS中为数据库实现EJB计时器服务。

的persistence.xml

path: ${JBOSS_HOME}\common\deploy\jboss-ejb3-timerservice-mk2.jar\META-INF\persistence.xml

<jta-data-source>java:/TestSybaseDB</jta-data-source>

EJB2定时器-service.xml中

path: ${JBOSS_HOME}\server\default\deploy\ejb2-timer-service.xml

<depends>jboss.jdbc:datasource=TestSybaseDB,service=metadata</depends>
<depends optional-attribute-name="DataSource">jboss.jca:service=DataSourceBinding,name=TestSybaseDB</depends>


但是为了在Wildfly AS中实现,我根据Sybase DB转换了timer-sql.properties的内容。

timer-sql.properties

path: ${JBOSS_HOME}\modules\system\layers\base\org\jboss\as\ejb3\main\timers\timer-sql.properties

create-table=CREATE TABLE JBOSS_EJB_TIMER (ID VARCHAR PRIMARY KEY NOT NULL, TIMED_OBJECT_ID VARCHAR NOT NULL, INITIAL_DATE DATETIME, REPEAT_INTERVAL BIGINT, NEXT_DATE DATETIME, PREVIOUS_RUN DATETIME, PRIMARY_KEY VARCHAR, INFO VARCHAR, TIMER_STATE VARCHAR, SCHEDULE_EXPR_SECOND VARCHAR, SCHEDULE_EXPR_MINUTE VARCHAR, SCHEDULE_EXPR_HOUR VARCHAR,SCHEDULE_EXPR_DAY_OF_WEEK VARCHAR, SCHEDULE_EXPR_DAY_OF_MONTH VARCHAR, SCHEDULE_EXPR_MONTH VARCHAR, SCHEDULE_EXPR_YEAR VARCHAR, SCHEDULE_EXPR_START_DATE VARCHAR, SCHEDULE_EXPR_END_DATE VARCHAR, SCHEDULE_EXPR_TIMEZONE VARCHAR, AUTO_TIMER SMALLINT, TIMEOUT_METHOD_NAME VARCHAR, TIMEOUT_METHOD_DECLARING_CLASS VARCHAR, TIMEOUT_METHOD_DESCRIPTOR VARCHAR, CALENDAR_TIMER SMALLINT, PARTITION_COL VARCHAR NOT NULL);
create-timer=INSERT INTO JBOSS_EJB_TIMER (ID, TIMED_OBJECT_ID, INITIAL_DATE, REPEAT_INTERVAL, NEXT_DATE, PREVIOUS_RUN, PRIMARY_KEY, INFO, TIMER_STATE, SCHEDULE_EXPR_SECOND, SCHEDULE_EXPR_MINUTE, SCHEDULE_EXPR_HOUR, SCHEDULE_EXPR_DAY_OF_WEEK, SCHEDULE_EXPR_DAY_OF_MONTH, SCHEDULE_EXPR_MONTH, SCHEDULE_EXPR_YEAR, SCHEDULE_EXPR_START_DATE, SCHEDULE_EXPR_END_DATE, SCHEDULE_EXPR_TIMEZONE, AUTO_TIMER, TIMEOUT_METHOD_NAME, TIMEOUT_METHOD_DECLARING_CLASS, TIMEOUT_METHOD_DESCRIPTOR, CALENDAR_TIMER, PARTITION_COL) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25);
update-timer=UPDATE JBOSS_EJB_TIMER SET NEXT_DATE=$1, PREVIOUS_RUN=$2, TIMER_STATE=$3 WHERE TIMED_OBJECT_ID=$4 and ID=$5 AND PARTITION_COL=$6;
delete-timer=DELETE FROM JBOSS_EJB_TIMER WHERE TIMED_OBJECT_ID=$1 and ID=$2 AND PARTITION_COL=$3;
load-all-timers=SELECT ID, TIMED_OBJECT_ID, INITIAL_DATE, REPEAT_INTERVAL, NEXT_DATE, PREVIOUS_RUN, PRIMARY_KEY, INFO, TIMER_STATE, SCHEDULE_EXPR_SECOND, SCHEDULE_EXPR_MINUTE, SCHEDULE_EXPR_HOUR, SCHEDULE_EXPR_DAY_OF_WEEK, SCHEDULE_EXPR_DAY_OF_MONTH, SCHEDULE_EXPR_MONTH, SCHEDULE_EXPR_YEAR, SCHEDULE_EXPR_START_DATE, SCHEDULE_EXPR_END_DATE, SCHEDULE_EXPR_TIMEZONE, AUTO_TIMER, TIMEOUT_METHOD_NAME, TIMEOUT_METHOD_DECLARING_CLASS, TIMEOUT_METHOD_DESCRIPTOR, CALENDAR_TIMER FROM JBOSS_EJB_TIMER WHERE TIMED_OBJECT_ID=$1 AND PARTITION_COL=$2;
load-timer=SELECT ID, TIMED_OBJECT_ID, INITIAL_DATE, REPEAT_INTERVAL, NEXT_DATE, PREVIOUS_RUN, PRIMARY_KEY, INFO, TIMER_STATE, SCHEDULE_EXPR_SECOND, SCHEDULE_EXPR_MINUTE, SCHEDULE_EXPR_HOUR, SCHEDULE_EXPR_DAY_OF_WEEK, SCHEDULE_EXPR_DAY_OF_MONTH, SCHEDULE_EXPR_MONTH, SCHEDULE_EXPR_YEAR, SCHEDULE_EXPR_START_DATE, SCHEDULE_EXPR_END_DATE, SCHEDULE_EXPR_TIMEZONE, AUTO_TIMER, TIMEOUT_METHOD_NAME, TIMEOUT_METHOD_DECLARING_CLASS, TIMEOUT_METHOD_DESCRIPTOR, CALENDAR_TIMER FROM JBOSS_EJB_TIMER WHERE TIMED_OBJECT_ID=$1 and ID=$2 AND PARTITION_COL=$3;
create-table.hsql=CREATE TABLE JBOSS_EJB_TIMER (ID VARCHAR PRIMARY KEY NOT NULL, TIMED_OBJECT_ID VARCHAR NOT NULL, INITIAL_DATE DATETIME, REPEAT_INTERVAL BIGINT, NEXT_DATE DATETIME, PREVIOUS_RUN DATETIME, PRIMARY_KEY VARCHAR, INFO VARCHAR, TIMER_STATE VARCHAR, SCHEDULE_EXPR_SECOND VARCHAR, SCHEDULE_EXPR_MINUTE VARCHAR, SCHEDULE_EXPR_HOUR VARCHAR,SCHEDULE_EXPR_DAY_OF_WEEK VARCHAR, SCHEDULE_EXPR_DAY_OF_MONTH VARCHAR, SCHEDULE_EXPR_MONTH VARCHAR, SCHEDULE_EXPR_YEAR VARCHAR, SCHEDULE_EXPR_START_DATE VARCHAR, SCHEDULE_EXPR_END_DATE VARCHAR, SCHEDULE_EXPR_TIMEZONE VARCHAR, AUTO_TIMER SMALLINT, TIMEOUT_METHOD_NAME VARCHAR, TIMEOUT_METHOD_DECLARING_CLASS VARCHAR, TIMEOUT_METHOD_DESCRIPTOR VARCHAR, CALENDAR_TIMER SMALLINT, PARTITION_COL VARCHAR NOT NULL);CREATE INDEX JBOSS_EJB_TIMER_IDENX ON JBOSS_EJB_TIMER (PARTITION_COL, TIMED_OBJECT_ID);

standalone-full-ha.xml中的计时器服务定义

<timer-service thread-pool-name="timer" default-data-store="clustered-store">
    <data-stores>
        <database-data-store name="clustered-store" datasource-jndi-name="java:/TestSybaseDB" partition="timer"/>
    </data-stores>
</timer-service>

我收到以下错误:

错误

ERROR [org.jboss.as.ejb3] (MSC service thread 1-2) JBAS014263: Cannot create table for timer persistence: com.sybase.jdbc4.jdbc.SybSQLException: There is already an object named 'JBOSS_EJB_TIMER' in the database.

at com.sybase.jdbc4.tds.Tds.a(Unknown Source)
at com.sybase.jdbc4.tds.Tds.nextResult(Unknown Source)
at com.sybase.jdbc4.jdbc.ResultGetter.nextResult(Unknown Source)
at com.sybase.jdbc4.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc4.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc4.jdbc.SybStatement.updateLoop(Unknown Source)
at com.sybase.jdbc4.jdbc.SybStatement.executeUpdate(Unknown Source)
at com.sybase.jdbc4.jdbc.SybStatement.executeUpdate(Unknown Source)
at org.jboss.jca.adapters.jdbc.WrappedStatement.executeUpdate(WrappedStatement.java:375)
at org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence.runCreateTable(DatabaseTimerPersistence.java:150) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence.start(DatabaseTimerPersistence.java:117) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_67]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_67]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_67]

从上面的错误中,我认为create-table中的timer-sql.properties导致了问题,因此,我尝试删除它,但收到以下错误。

ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.ejb3.timerService.timerPersistence.clustered-store: org.jboss.msc.service.StartException in service jboss.ejb3.timerService.timerPersistence.clustered-store: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_67]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_67]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_67]
Caused by: java.lang.NullPointerException
at org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence.runCreateTable(DatabaseTimerPersistence.java:146)
at org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence.start(DatabaseTimerPersistence.java:117)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
... 3 more

ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "ejb3"),
("service" => "timer-service"),
("database-data-store" => "clustered-store")
]) - failure description: {"JBAS014671: Failed services" => {"jboss.ejb3.timerService.timerPersistence.clustered-store" => "org.jboss.msc.service.StartException in service jboss.ejb3.timerService.timerPersistence.clustered-store: Failed to start service
Caused by: java.lang.NullPointerException"}}

JBAS014777:   Services which failed to start:      service jboss.ejb3.timerService.timerPersistence.clustered-store: org.jboss.msc.service.StartException in service jboss.ejb3.timerService.timerPersistence.clustered-store: Failed to start service  

有没有人可以帮我解决错误并为Wildfly AS中定义的数据源配置EJB计时器服务。

1 个答案:

答案 0 :(得分:0)

我认为你可以删除timer-sql.properties文件的最后一行。 如果语句在Sybase中正常工作,它应该可以工作。

我已经使用了这个article,它对我很有用。我使用的是Postgres而不是Sybase