2009-09-08 70 views
0

當我按照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。我無法弄清楚這個問題。哪裏有問題?我怎樣才能解決這個問題?

回答

1

這只不過是一個簡單的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