简体   繁体   中英

EclipseLink into OSGI Bundle persistence.xml not found

I'm having some problem with EclipseLink. I'm using GlassFish v3.1 and I'm trying to use EclipseLink for my persistence layer. I followed all tutorials available on the Eclipse wiki without luck. My persistence.xml file cannot be parsed and I receive this error while trying to create the EntityManagerFactory:

org.eclipse.persistence.exceptions.PersistenceUnitLoadingException Exception Description: An exception was thrown while processing persistence.xml from URL: bundle://307.1:1/

Here is my persistence.xml located in /WEB-INF/classes/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>

I added this line to my MANIFEST.MF:

JPA-PersistenceUnits: generic

I can now confirm that it's a bug in EclipseLink. The work around to your problem is to either get hold of EntityManagerFactory using JNDI lookup or @PersistenceUnit instead of doing Persistence.createEntityManagerFactory().

1) It looks like you are trying to use OSGi/JPA from your WAB. Correct? 2) Can you tell if you have installed any new eclipselink bundles in your system? If so, what are they? 3) Can you provide stack trace?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM