I would like to put some hibernate configuration in the properties file to make it editable without assembly and deployment.
I tried to solve my problem by following the Create JPA EntityManager instructions without the persistence.xml configuration file
app.properties:
hibernate.show_sql=true hibernate.dialect=org.hibernate.dialect.MySQLDialect hibernate.hbm2ddl.auto=validate hibernate.show_sql=true hibernate.format_sql=true hibernate.default_schema=myschema
persistence.xml
<?xml version="1.0" encoding="UTF-8"?> <persistence 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" version="1.0"> <persistence-unit name="pu"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>jdbc/appDatasource</jta-data-source> <properties> <property name="jboss.entity.manager.factory.jndi.name" value="java:/appEntityManagerFactory"/> </properties> </persistence-unit> </persistence>
In the initialization code, the application executes the following sequence (which finds the properties),
Properties props = new Properties(); InputStream is = ClassLoader.getSystemResourceAsStream( "app.properties" ); props.load( is ); Persistence.createEntityManagerFactory( "pu", props );
but with the error message does not appear:
INFO [SessionFactoryImpl] building session factory INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured ERROR [STDERR] javax.persistence.PersistenceException: [PersistenceUnit: pu] Unable to build EntityManagerFactory
Can anyone understand what might be wrong in my configuration?
Versions: JBoss 4.3 Seam: 2.1.2
EDIT:
JBoss JNDI enters "pu" as the unit of continuity:
persistence.units:ear=app.ear,jar=app.jar,unitName=pu (class: org.hibernate.impl.SessionFactoryImpl)
java java-ee hibernate jpa seam
stacker Oct 14 '10 at 16:29 2010-10-14 16:29
source share