Persistence.xml

问题描述:

当我按照restful project in netbeans然后我得到的错误。Persistence.xml

SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method 
java.lang.RuntimeException: java.lang.ClassNotFoundException: oracle.toplink.essentials.PersistenceProvider 
Caused by: java.lang.ClassNotFoundException: oracle.toplink.essentials.PersistenceProvider 

SEVERE: Exception while deploying the app 
java.lang.RuntimeException: java.lang.ClassNotFoundException: oracle.toplink.essentials.PersistenceProvider 
Caused by: java.lang.ClassNotFoundException: oracle.toplink.essentials.PersistenceProvider 

我确定问题出在persistence.xml中。这是我的persistence.xml:)

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> 
    <persistence-unit name="ayniPU" transaction-type="JTA"> 
    <provider>oracle.toplink.essentials.PersistenceProvider</provider> 
    <jta-data-source>jndi/ayni</jta-data-source> 
    <properties> 
     <property name="toplink.ddl-generation" value="drop-and-create-tables"/> 
     <property name="toplink.jdbc.user" value="root"/> 
    <property name="toplink.jdbc.password" value="3774634"/> 
    </properties> 
    </persistence-unit> 
</persistence> 

我使用toplink连接mysql数据库。我有glassfishv3和Netbeans6.7。我无法弄清楚这个问题。哪里有问题?我怎样才能解决这个问题?

这只不过是一个简单的CLASSPATH问题。您的CLASSPATH中没有TopLink JAR。 NetBeans假设TopLink是您的JPA实现。

查找JAR并将它们提供给NetBeans或作为JPA实现切换到Hibernate。

+0

我从http://www.oracle.com/technology/software/products/ias/htdocs/1111topsoft.html下载了Oracle TopLink 11gRelease 1,然后将JAR加载到我的项目中。什么都没有发生 – Iguramu 2009-09-08 10:54:37

+0

您是否已将它们添加到您的项目的NetBeans CLASSPATH中?下载是必要的,但不够。 – duffymo 2009-09-08 22:49:32