2011-01-31 56 views
3

我在EclipseLink中遇到了一些問題。我使用的是GlassFish v3.1,我正在嘗試爲我的持久層使用EclipseLink。我遵循Eclipse wiki上提供的所有教程,但沒有幸運。我的persistence.xml文件不能被解析,我收到此錯誤,而試圖創建的EntityManagerFactory:將EclipseLink導入OSGI包persistence.xml未找到

org.eclipse.persistence.exceptions.PersistenceUnitLoadingException 異常說明:從URL處理persistence.xml中引發異常:束://307.1:1/

這是我的persistence.xml位於/ WEB-INF /類/ META-INF /:

<persistence version="1.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_1_0.xsd"> 
    <persistence-unit name="generic"> 
     <class>com.generic.domain.Service</class> 

     <properties> 
      <!-- Embedded MySQL Login --> 
      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> 
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306"/> 

      <!-- TODO: replace with connection pool --> 
      <property name="javax.persistence.jdbc.userid" value="root"/> 
      <property name="javax.persistence.jdbc.password" value=""/> 

      <property name="eclipselink.target-database" value="MySQL"/> 
      <property name="eclipselink.jdbc.read-connections.min" value="1"/> 
      <property name="eclipselink.jdbc.write-connections.min" value="1"/> 
      <property name="eclipselink.jdbc.batch-writing" value="JDBC"/> 

      <!-- Logging Settings --> 
      <property name="eclipselink.logging.level" value="FINE" /> 
      <property name="eclipselink.logging.thread" value="false" /> 
      <property name="eclipselink.logging.session" value="false" /> 
      <property name="eclipselink.logging.exceptions" value="true" /> 
      <property name="eclipselink.logging.timestamp" value="false"/>    
     </properties> 
    </persistence-unit> 
</persistence> 

我加入這一行到我的清單。 MF:

JPA-PersistenceUnits: generic 

回答

0

1)它看起來像你試圖從你的WAB使用OSGi/JPA。正確? 2)您能否告訴您是否在系統中安裝了任何新的eclipselink軟件包?如果是這樣,他們是什麼? 3)你能提供堆棧跟蹤嗎?

+0

1)true 2)我正在使用GlassFish v3.1中提供的EclipseLink捆綁包3)堆棧跟蹤:http://dinoz.mobi/stack.txt – MobileSam 2011-02-01 13:55:18

+0

1.您可以告訴你的WAB? 2.你可以告訴WAB的Bundle-ClassPath嗎? – Sahoo 2011-02-02 19:29:23

1

我現在可以確認這是EclipseLink中的一個錯誤。解決問題的方法是使用JNDI查找或@PersistenceUnit來獲取EntityManagerFactory,而不是執行Persistence.createEntityManagerFactory()。

相關問題