users@glassfish.java.net

Having trouble deplying EAR. Can't resolve persistence unit...

From: <glassfish_at_javadesktop.org>
Date: Sun, 18 Apr 2010 05:35:54 PDT

Hi,

I'm having a problem that should be very easy to troubleshoot, but I just can't figure it out. I must be making a stupid mistake somewhere. I've tried setting the logging to finest for javax.enterprise.system.tools.deployment, but it doesn't seem to give me any extra info.

If someone can tell me how to get verbose logging when deploying an application I can figure this out on my own. If not, my configuration is below. Are there any obvious mistakes?

I have a a very simple EAR with the following structure:

[code]
assembly-ear-1.0-SNAPSHOT.ear
-- /META-INF/*
-- /lib/domain-1.0-SNAPSHOT.jar <<< POJO Module
-- /lib/services-dao-api-1.0-SNAPSHOT.jar <<< POJO Module
-- services-dao-1.0-SNAPSHOT.jar <<< EJB Module
[/code]
I have the following persistence.xml file in the META-INF directory of the domain-1.0-SNAPSHOT.jar module:
[code]
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
                         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                         version="2.0"
                         xsi:schemaLocation="[...snip...]/persistence_2_0.xsd">

        <persistence-unit name="ItmaPU">
                <jta-data-source>itma-ds</jta-data-source>
                
                <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

                <exclude-unlisted-classes>false</exclude-unlisted-classes>

                <properties>
                        <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
                        <property name="eclipselink.target-database" value="PostgreSQL"/>
                </properties>
        </persistence-unit>
</persistence>
[/code]
I try to inject the persistence unit in my EJB module like this (I've also tried it without giving a name):
[code]
@PersistenceUnit(name = "ItmaPU")
private EntityManagerFactory emf;
[/code]
I let Maven generate my application.xml file. It looks like this:
[code]
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee"
                         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                         xsi:schemaLocation="[...snip...]/application_5.xsd"
                         version="5">
  <display-name>assembly-ejb</display-name>
  <module>
    <ejb>services-dao-1.0-SNAPSHOT.jar</ejb>
  </module>
  <library-directory>/lib</library-directory>
</application>
[/code]
I don't have an ejb-jar.xml file.

Whenever I deploy I get the error:
[code]
Could not resolve a persistence unit corresponding to the persistence-unit-ref-name
[ItmaPU] in scope of the module called
[assembly-ear-1.0-SNAPSHOT#services-dao-1.0-SNAPSHOT.jar]
[/code]
My data source appears to be named correctly:
[code]
./asadmin list-jndi-entries
...
itma-ds: org.glassfish.javaee.services.ResourceProxy
[/code]
I'm using Glassfish v3.1 built on April 16, 2010. I updated my config from something I used with Glassfish v2, so maybe I've overlooked something that changed between versions. I haven't added / removed any modules. My database connections are working.
[Message sent by forum member 'jptech']

http://forums.java.net/jive/thread.jspa?messageID=397629