open-libertyejb-timer

How to setup an EJB timerDataSource in Open Liberty


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?


Solution

  • It looks like your <dataSource> configuration is missing a few items:

    1. A <jdbcDriver> which points to the JDBC driver jar that corresponds with the DB you are using
    2. A <properties> element which identifies DB properties such as the DB server's hostname, port, and DB name.

    Since you mentioned using DerbyDB, here is an example of what Derby config might look like:

    <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>
    

    For additional info on configuring DataSources in Liberty, check out this doc:
    Configuring relational database connectivity in Liberty