users@glassfish.java.net

Re: Could not resolve a persistence unit in EAR

From: Witold Szczerba <pljosh.mail_at_gmail.com>
Date: Wed, 28 Apr 2010 14:51:55 +0200

2010/4/27 <glassfish_at_javadesktop.org>:
> Hi have a lots of problems while deploy my application
>
> Glassfish: GlassFish v3 (build 74.2)  (same on: GlassFish 3 (build 14))
> JPA 2.0, EJB 3.0
> JPA Provider: Hibernate
>
>
> Error:
> Exception while preparing the app : org.glassfish.deployment.common.DeploymentException: Could not resolve a persistence unit corresponding to the persistence-context-ref-name [xxx] in the scope of the module called [XXX-ear-0.0.1-SNAPSHOT#XXX-comp-firmenmgmt-0.0.1-SNAPSHOT.jar]. Please verify your application.
>
> My Application is packed as an EAR-File:
>
> ear
> + lib
> --  some libs
> --  pu.jar (with META-INF Folder - persistence.xml)
> xxx-comp-firmenmgmt-0.0.1-SNAPSHOT.jar (with Entites and EJBs)
> xxx-comp-projektmgmt-0.0.1-SNAPSHOT.jar (with Entites and EJBs)
> +META-INF
> -- application.xml
>
> The References from my Beans look like
> "  @PersistenceContext(name = "xxx") "
>
> my persistence.xml look like:
>        <persistence-unit name="xxx">
>                <provider>org.hibernate.ejb.HibernatePersistence</provider>
>                <jta-data-source>jdbc/xxx</jta-data-source>
>                <jar-file>../xxx-comp-firmenmgmt-0.0.1-SNAPSHOT.jar</jar-file>
>                <jar-file>../xxx-comp-projektmgmt-0.0.1-SNAPSHOT.jar</jar-file>
>                <exclude-unlisted-classes>false</exclude-unlisted-classes>
>                <properties>
>                        <property name="eclipselink.ddl-generation" value="create-tables" />
>                        <property name="eclipselink.ddl-generation.output-mode" value="database" />
>                        <property name="eclipselink.logging.level" value="OFF" />
>
>                        <property name="hibernate.hbm2ddl.auto" value="update" />
>                        <property name="hibernate.show_sql" value="false"></property>
>                </properties>
>        </persistence-unit>
> </persistence>
>
>
> try a lots of different declarations and positions of the persistence.xml but nothing work
> Hope somebody have any good idea
>
> thanks a lot
> Dom
> [Message sent by forum member 'dadidom']
>

I had the same issue and here was a discussion about it once or maybe
more. It was, however, happening with Glassfish 2.
My EJB modules started to see and use single persistence unit once I
moved it into root of my EAR (instead of /lib).

--
Witold Szczerba