WAS Liberty 8.5.5.4,JPA 2.0 - 发现的实现:NONE

时间:2015-06-11 15:09:06

标签: java jpa websphere-liberty

我能够让JPA使用eclipse Luna并安装eclipseLink(并使用3个jar创建了一个User Lib)。

但是,我现在已经转移到Rational Application Developer(RAD)并尝试使用随WAS Liberty提供的JPA。我最初使用RAD JPA facet来配置JPA,然后编辑persistence.xml。

我收到此错误: 引起:javax.persistence.PersistenceException:没有持久性提供程序可用于" test2"在尝试以下发现的实现之后:NONE

我认为(总是很危险)NONE是一个配置错误,在解决之前我什么也做不了......

我已将wlp \ dev \ api \ spec \ com.ibm.ws.javaee.persistence.2.0_1.0.1.jar复制到WEB-INF / lib中,并将其包含在我的java构建路径中。

如下所示,我猜测我的提供商不正确,并尝试了几个值......

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence     http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="test2" transaction-type="RESOURCE_LOCAL">
    <!-- provider>org.eclipse.persistence.jpa.PersistenceProvider</provider-->
    <!-- provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider-->
    <provider>com.ibm.websphere.persistence.PersistenceProviderImpl</provider>
    <non-jta-data-source>java:comp/env/New Generic JDBC</non-jta-data-source>
    <class>com.ibm.analytics.jpa.Dimtask</class>
    <properties>
        <property name="openjpa.jdbc.Schema" value="RM"/>
        <property name="javax.persistence.jdbc.url" value="jdbc:netezza://netezza-1.site.ibm.com:5480/DATABASENAME"/>
        <property name="javax.persistence.jdbc.user" value="jspoon"/>
        <property name="javax.persistence.jdbc.password" value="xxxxxxx"/>
        <property name="javax.persistence.jdbc.driver" value="org.netezza.Driver"/>
    </properties>
</persistence-unit>
</persistence>

我还能做些什么才能超越NONE?

这是persistence.xml的更新版本,我刚刚注释掉了提供程序。

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="test2" transaction-type="RESOURCE_LOCAL">
    <!-- provider>org.eclipse.persistence.jpa.PersistenceProvider</provider-->
    <!-- provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider-->
    <!-- provider>com.ibm.websphere.persistence.PersistenceProviderImpl</provider-->
    <non-jta-data-source>java:comp/env/New Generic JDBC</non-jta-data-source>
    <class>com.ibm.analytics.jpa.Dimtask</class>
    <properties>
        <property name="openjpa.jdbc.Schema" value="RM"/>
        <property name="javax.persistence.jdbc.url" value="jdbc:netezza://netezza-1.boulder.ibm.com:5480/BACC_TST_ISHANGO_DW"/>
        <property name="javax.persistence.jdbc.user" value="jspoon"/>
        <property name="javax.persistence.jdbc.password" value="C0ke4y0u"/>
        <property name="javax.persistence.jdbc.driver" value="org.netezza.Driver"/>
    </properties>
</persistence-unit>
</persistence>

我使用JPA Tooling创建了我的Entity类,并使用简单的junit测试来调用命名查询。第一步是创建EMF,它在我的类中是静态的(因此没有测试实际上正在运行,它在实例化时创建静态变量失败):

static EntityManagerFactory emf = Persistence.createEntityManagerFactory( "test2" );

这与eclipse和eclipseLink之前使用的代码完全相同。

0 个答案:

没有答案