3

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
MobileSam
  • 818
  • 8
  • 14

2 Answers2

1

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().

Sahoo
  • 94
  • 2
  • Thanks for the feedback, I still have a problem, when I use @PersistenceUnit the EntityManager is not injected in my servlet when I need it, but only once before anything can get hold on it. I'm using Jersey implementation of RESTFul services. Thanks for your help. – MobileSam Feb 11 '11 at 13:35
0

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?

Sahoo
  • 94
  • 2
  • 1) true 2) I'm using the EclipseLink bundle that are available in GlassFish v3.1 3) Stack trace : http://dinoz.mobi/stack.txt – MobileSam Feb 01 '11 at 13:55
  • 1. Can you tell the structure of your WAB? 2. Can you tell the Bundle-ClassPath of the WAB? – Sahoo Feb 02 '11 at 19:29
  • - META-INF/MANIFEST.MF - WEB-INF/web.xml - WEB-INF/classes/com/... - WEB-INF/classes/META-INF/persistence.xml - src/main/test/java Bundle-ClassPath: WEB-INF/classes I can find the persistence.xml under WEB-INF/classes/META-INF/ in the WAB. Thanks for your help. – MobileSam Feb 03 '11 at 00:58
  • I have been able to reproduce this issue using a simple test case. It appears to be a bug (most likely) in eclipselink component of glassfish. Do you mind creating a bug against GlassFish under entity-persistence subcategory? – Sahoo Feb 06 '11 at 17:32