Я переношу приложение EAR с JBoss AS 6 на Wildfly AS 8.2.0. Во время работы я столкнулся с проблемой при реализации EJB timer service
в Wildfly AS для источника данных TestSybaseDB
, определенного в standalone-full-ha.xml
.Как реализовать службу таймера EJB в Wildfly AS 8 для источника данных
FYI, что ниже, файлы, связанные с JBoss AS 6, связанные с реализацией службы таймера EJB3 для источника данных TestSybaseDB
. В нижележащих файлах JBoss 6 AS определено имя источника данных, и я считаю, что этих изменений достаточно для реализации службы таймера EJB в JBoss 6 AS для базы данных.
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, я преобразовал содержание timer-sql.properties
в соответствии с Sybase DB.
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);
Таймер в автономном-полной 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
Может кто-нибудь, пожалуйста, помогите мне в решении ошибки и настроить службу таймера EJB для источника данных, определенных в Wildfly AS.
Большое спасибо за ответ. Марсель .. Я попробую это. – sridhar
Я все еще получаю «ERROR [org.jboss.as.ejb3] (поток обслуживания MSC 1-2) JBAS014263: не удается создать таблицу для сохранения таймера: com.sybase.jdbc4.jdbc.SybSQLException: уже существует объект с именем ' JBOSS_EJB_TIMER 'в базе данных. "после удаления последней строки .. Marcel. – sridhar
@sridhar Не могли бы вы попытаться найти все объекты с таким именем? Запрос - это что-то вроде select * from sysobjects как o, где o.name нравится «% JBOSS_EJB_TIMER%»; –