【问题标题】:How to setup an EJB timerDataSource in Open Liberty如何在 Open Liberty 中设置 EJB timerDataSource
【发布时间】:2019-10-16 23:31:02
【问题描述】:

我尝试部署一个 Java EE 应用程序,其中包含多个 EJB 计时器服务(persistence=true)。 服务器抱怨没有定义数据源:

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.

ejbPersistentTimer-3.2 功能已打开。 我找不到如何在 server.xml 文件中配置此类数据源的示例

我试过了:

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

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

但这似乎还不够?我是否也需要激活 DerbyDB 作为一项功能?

【问题讨论】:

    标签: open-liberty ejb-timer


    【解决方案1】:

    您的 &lt;dataSource&gt; 配置似乎缺少一些项目:

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

    由于您提到使用 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 中配置数据源的更多信息,请查看此文档:
    Configuring relational database connectivity in Liberty

    【讨论】:

    • 谢谢。我已经尝试使用我现有的 psql 数据源。问题是标签 transactional="true"。在我将 timerDataSource 的值更改为“false”后,它可以工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多