1

I try to deploy a Java EE Application containing several EJB Timer Services (with persistence=true). The server complains that no datasource was defined:

Caused by: javax.ejb.EJBException: See nested exception; nested exception is: java.lang.IllegalStateException: The ejbPersistentTimer feature is enabled, but the defaultEJBPersistentTimerExecutor persistent executor cannot be resolved. The most likely cause is that the DefaultDataSource datasource has not been configured. Persistent EJB timers require a datasource configuration for persistence.

The ejbPersistentTimer-3.2 feature is turned on. I can not find an example how to configure such a datasource in the server.xml file

I tried:

<dataSource id="timerDataSource" jndiName="jdbc/timerDataSource">
</dataSource>

<databaseStore id="EJBTimerDatabaseStore"
    tablePrefix="EJBTimer_" dataSourceRef="timerDataSource" />
<persistentExecutor
    id="defaultEJBPersistentTimerExecutor"
    taskStoreRef="EJBTimerDatabaseStore" />

But this seems to be not enoght? Did I need to activate DerbyDB as a feature too?

4

1 回答 1

2

看起来您的<dataSource>配置缺少一些项目:

  1. A<jdbcDriver>指向与您正在使用的 DB 对应的 JDBC 驱动程序 jar
  2. 标识数据库属性的<properties>元素,例如数据库服务器的主机名、端口和数据库名称。

由于您提到使用 DerbyDB,以下是 Derby 配置的示例:

<dataSource id="timerDataSource" jndiName="jdbc/timerDataSource">
    <jdbcDriver libraryRef="DerbyLib"/>
    <properties.derby.embedded databaseName="${server.config.dir}/data/EJBTimerDB" createDatabase="create"/>
</dataSource>

<library id="DerbyLib">
    <fileset dir="${server.config.dir}/derbyDriverDir/"/>
</library>

有关在 Liberty 中配置数据源的更多信息,请查看此文档:
在 Liberty 中配置关系数据库连接

于 2019-05-31T13:22:06.030 回答