WAR and JPA no entities scanned
rlogiacco Jun 22, 2012 6:58 AMHi, I'm trying to deploy in JBoss AS7.1.1.Final a war which contains annotated entities. It seems the entities contained in the WEB-INF/classes directory are not scanned.
I've tried two different approaches: with container managed JPA and with application managed JPA (within Spring) and neither of the two works while the latter works perfectly fine in Tomcat.
My persistence.xml file (which get's renamed to jpa-persistence.xml when I switch to application managed JPA) content is:
{code:xml}<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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="persistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>java:jboss/datasources/TalentDS</non-jta-data-source>
<!-- this should not be necessary! if I add them then everything goes fine
<class>org.agileware.talent.Account</class>
<class>org.agileware.talent.Application</class>
<class>org.agileware.talent.Candidate</class>
<class>org.agileware.talent.Experience</class>
<class>org.agileware.talent.Offer</class>
-->
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
<!-- value="create" to build a new database on each run; value="update" to modify an existing database; value="create-drop"
means the same as "create" but also drops tables when Hibernate closes; value="validate" makes no changes to the database -->
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy" />
<property name="hibernate.connection.charSet" value="UTF-8" />
<property name="hibernate.validator.apply_to_ddl" value="false" />
<property name="hibernate.validator.autoregister_listeners" value="false" />
<!-- I've tried with and without the following, no joy and I don't even know what it does-->
<property name="jboss.entity.manager.factory.jndi.name" value="java:jboss/LibraryEntityManagerFactory" />
</properties>
</persistence-unit>
</persistence>
{code}
Obviously if I have the file named persistence.xml and I leave the spring configuration as it is my persistenceUnit is processed twice, once by JBoss and once by Spring.
What am I missing?