我在使用 EclipseLink 时遇到了一些问题。我正在使用 GlassFish v3.1,并且我正在尝试将 EclipseLink 用于我的持久层。我没有运气就遵循了 Eclipse wiki 上提供的所有教程。我的 persistence.xml 文件无法解析,并且在尝试创建 EntityManagerFactory 时收到此错误:
org.eclipse.persistence.exceptions.PersistenceUnitLoadingException 异常描述:处理来自URL的persistence.xml时抛出异常:bundle://307.1:1/
这是位于 /WEB-INF/classes/META-INF/ 中的我的 persistence.xml:
<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>
我将此行添加到我的 MANIFEST.MF 中:
JPA-PersistenceUnits: generic