2

有没有人尝试使用 Apache 的 DeltaSpike 在 Jetty 中设置事务性?我有一个 web 应用程序,我试图在使用 CDI 并具有 JTA 数据源的 Jetty 中运行。我的事务管理器没有被注入,它为空,因此导致错误。我包含了 deltaspike jpa jar 并按照下面给出的链接中的说明进行操作,但到目前为止它还没有工作。当我在 hibernate 类中进行深入调试时,我可以看到我的配置默认为 NOJTAPlatform,就好像没有配置 JTA。

任何想法,将不胜感激。

    <dependency>
    <groupId>org.apache.deltaspike.modules</groupId>
    <artifactId>deltaspike-jpa-module-impl</artifactId>
    <version>0.5</version>
</dependency>

链接到 DeltaSpike 配置:

http://deltaspike.apache.org/jpa.html

我在 persistence.xml 中指定的数据源:

<persistence-unit name="database" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>jdbc/myDS</jta-data-source>
    <properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
        <property name="hibernate.archive.autodetection" value="class"/>
        <property name="hibernate.id.new_generator_mappings" value="true"/>
    </properties>
</persistence-unit>
4

1 回答 1

1

您在 Jetty 中使用了哪个 CDI 实现,它配置正确吗?

通过尝试一些简单的注入来确保通用 CDI 注入正常工作?

确保包含核心增量峰值依赖项 deltaspike-core-api 和 deltaspike-core-impl

根据您设置 CDI 的方式,您可能还需要 deltaspike-cdictrl-api 和特定的 cdictrl api。

更多信息请访问http://deltaspike.apache.org/documentation.html#configuration-of-deltaspike-core

于 2014-02-08T11:37:40.883 回答