Search code examples
websphere-libertyopen-libertyjsr352

Liberty Batch function not using database persistence for job repository


I'm trying to use database persistence with the Open Liberty batch features. However, I'm seeing nothing inserted into my DB tables and I see this message in messages.log:

... I CWWKY0005I: The batch In-Memory persistence service is activated.

server.xml

In my server configuration, I have:


    <!-- Batch features -->
    <featureManager>
        <feature>cdi-3.0</feature>
        <feature>batch-2.0</feature>
        <feature>batchManagement-1.0</feature>
        ...
    <featureManager>

    <!-- Configure JDBC library -->
    <library id="jdbcLib">
        <fileset dir="/config/lib/global" includes="*.jar"/>
    </library>

    <!-- Configure dataSource -->
    <dataSource id="batchDB" jdbcDriverRef="jdbcLib">
      <properties.db2.jcc>
       ... a bunch of properties ...
      </properties.db2.jcc> 
    </dataSource>

    <!-- Reference datasource with batch DB store -->

    <batchPersistence jobStoreRef="BatchDatabaseStore"/>

    <databaseStore id="BatchDatabaseStore"
                   dataSourceRef="batchDB" schema="JBATCH" tablePrefix=""
                   createTables="false"/>

What am I doing wrong?

NOTE

Sometimes when batch database persistence is working the CWWKY0005I message is followed by the message

CWWKY0008I: The batch feature is using persistence type JPA.

as the batch persistence component dynamically activates later on, but this is NOT happening in my case.


Solution

  • In your server.xml config, you missed a layer of wrappering (abstraction) here by referencing the <library> directly with jdbcDriverRef="jdbcLib" when you should have referenced a <jdbcDriver>.

    So you could have used in your server.xml either:

        <library id="jdbcLib">
           ...
    
        <dataSource id="batchDB">
          <jdbcDriver libraryRef="jdbcLib"/>
           ... 
        </dataSource>
    

    or, alternately

        <library id="jdbcLib">
           ...
        <jdbcDriver id="myJDBCDriver" libraryRef="jdbcLib"/>
    
        <dataSource id="batchDB" jdbcDriverRef="myJDBCDriver">
           ... 
    

    to have your dataSource referencing a jdbcDriver which, in turn, references a library.