users@glassfish.java.net

CDI and persistence units: no entities found?

From: <glassfish_at_javadesktop.org>
Date: Wed, 21 Jul 2010 07:40:28 PDT

I have an EJB with a @PersistenceContext in it.

The EJB is injected into a @SessionScoped class via @Instance<DAO>, where DAO is one of the business interfaces of the EJB.

(I have recently gotten the @PersistenceContext EntityManager not to be null by adding META-INF/beans.xml to the EJB's jar file, even though the EJB and its related classes use nothing from the CDI packages. I mention this in case it is relevant to the current problem.)

So, the EntityManager is non-null. Hooray!

But it seems like the persistence unit is entirely devoid of entities.

I have what I think is a pretty standard (worked for me in the past) setup where I have several *-jpa.jar files in the lib directory of my ear, each of which contains various entity classes. I then have one single META-INF/persistence.xml file in another library jar in the same directory.

That persistence.xml does not list any entity classes or jar files in it; it relies on the container to discover all the entity classes automatically. It appears however that the container is not discovering any such entities.

Here is the (utterly straightforward) persistence.xml:
[code]
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
  <persistence-unit name="LEAD" transaction-type="JTA">
    <jta-data-source>jdbc/LEAD</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
      <property name="hibernate.format_sql" value="true" />
      <property name="hibernate.show_sql" value="true" />
      <property name="eclipselink.jdbc.native-sql" value="true" />
      <property name="eclipselink.logging.level" value="FINEST" />
      <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.MySQLPlatform" />
      <property name="openjpa.Log" value="DefaultLevel=TRACE, SQL=TRACE, Schema=TRACE" />
      <property name="openjpa.jdbc.Schema" value="LEAD" />
    </properties>
  </persistence-unit>
</persistence>
[/code]

Thanks for any help (as always).

Best,
Laird
[Message sent by forum member 'ljnelson']

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