我是JPA的新手。我使用maven,eclipselink 2.0和jpa 2.0。我已经使用数据库连接创建了这些实体。这是我的persistence.xmlJPA 2.0和EclipseLink 2.0的身份验证错误
<?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="certifications" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/com/ni/ds_edata_soa_nontx</jta-data-source>
<class>com.ni.apps.engineering.certification.entities.NicdsCliCertificationStg</class>
<class>com.ni.apps.engineering.certification.entities.NicdsCliCertificationStgPK</class>
<class>com.ni.apps.engineering.certification.entities.NicdsCliUpMapping</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.password" value="soa_user"/>
<property name="javax.persistence.jdbc.user" value="soa_user"/>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
<property name="eclipselink.logging.level.sql" value="FINE"/>
</properties>
</persistence-unit>
</persistence>
这是我试图运行应用程序时得到的错误。
detailMessage“异常[EclipseLink-4002](Eclipse持久性服务 - 2.3.1.v20111018-r10243):org.eclipse.persistence.exceptions.DatabaseException \ r \ n内部异常:java.sql.SQLException:java.sql .SQLException:用户:NI,未通过身份验证。\ r \ n错误代码:0“(id = 114)
正如您所看到的,在我的持久性中没有任何称为”NI“的东西。唯一被称为NI的是我从中拉出表来创建实体的模式。 JTA数据源与我的weblogic中的内容完全相同。
任何想法?
- 编辑 - 这是我得到的EntityManager
private EntityManagerFactory emf;
protected EntityManager getEntityManager(){
if(emf == null){
emf = Persistence.createEntityManagerFactory("certifications");
}
return emf.createEntityManager(); //This is where it fails
}
试过了,但没有奏效。我添加了更多信息。谢谢! – Nacho321 2014-08-27 17:33:16
您可以从数据源连接正常WebLogic控制台验证?它可以是您在WebLogic中数据源配置使用的用户“NI”和它的用户名或密码在WebLogic中被定义incorrecly。 – 2014-08-28 07:44:12
不,weblogic数据源有一个完全不同的用户/密码组合。它和我在persistence.xml中的一样 – Nacho321 2014-08-28 13:33:26