2

有没有人能够让 EclipseLink JPA povider 在带有容器管理事务的 WAS Liberty Profile 中工作?我已经使用 JPA Container 设置配置了我的 server.xml 文件以覆盖默认的 OpenJPA 实现,但这会导致副作用,即当通过具有事务传播注释的 EJB 访问时,EntityManager 不再参与容器事务。

我还尝试将“eclipselink.target-server”属性设置为“WebSpeher_7”,但是当我这样做时,我在 com.ibm.ws.Transaction.TransactionManagerFactory 类上得到了 ClassNotFoundException。

4

2 回答 2

4

下午好。看起来您遇到了错误 407279 ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=407279 )。

您可以通过使用以下更改修改 org.eclipse.persistence.transaction.was.WebSphereTransactionController 来解决此问题:

public class WebSphereTransactionController extends JTATransactionController {
    // Class and method to execute to obtain the TransactionManager
    protected final static String TX_MANAGER_FACTORY_CLASS = "com.ibm.tx.jta.TransactionManagerFactory";
    // OLD VALUE --> "com.ibm.ws.Transaction.TransactionManagerFactory";

希望这可以帮助!一定要使用 EclipseLink 2.5.2,因为它有另一个重要的变化(错误 412627),以便与 Liberty 一起工作!

于 2014-01-03T19:33:14.103 回答
0

我不得不用 liberty 16.0.0.2、Spring 4.X 和 EclipseLink 5.2.X 改变很多东西

我删除了 persistence.xml 文件并将 spring xml 配置更改为:

<bean id="transactionManager"
    class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>


<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="datasource" />
    <property name="persistenceUnitName" value="PERSISTENCE_UNIT"></property>
    <property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
    <property name="packagesToScan">
        <list>
            <value>ENTITIES_PACKAGE</value>
        </list>
    </property>
    <property name="jpaPropertyMap">
  <map>
    <entry key="eclipselink.weaving" value="false"/>
  </map>
</property>
    </bean>

对于 server.xml

<jpa defaultPersistenceProvider="org.eclipse.persistence.jpa.PersistenceProvider"/>

<featureManager>
    <feature>servlet-3.0</feature>
    <feature>jdbc-4.0</feature>
    <feature>jpa-2.0</feature>
    <feature>localConnector-1.0</feature>
    <feature>jsp-2.2</feature>
</featureManager>
于 2016-08-08T15:22:47.433 回答