gpt4 book ai didi

java - 找不到 EclipseLink 到 OSGI Bundle persistence.xml

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:17:42 25 4
gpt4 key购买 nike

我在使用 EclipseLink 时遇到了一些问题。我使用的是 GlassFish v3.1,我正在尝试将 EclipseLink 用于我的持久层。我遵循了 Eclipse wiki 上提供的所有教程,但运气不佳。我的 persistence.xml 文件无法解析,我在尝试创建 EntityManagerFactory 时收到此错误:

org.eclipse.persistence.exceptions.PersistenceUnitLoadingException Exception Description: An exception was thrown while processing persistence.xml from URL: 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

最佳答案

我现在可以确认这是 EclipseLink 中的错误。解决您的问题的方法是使用 JNDI 查找或 @PersistenceUnit 获取 EntityManagerFactory 而不是执行 Persistence.createEntityManagerFactory()。

关于java - 找不到 EclipseLink 到 OSGI Bundle persistence.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4852100/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com