EntityManager is null
metal610 Mar 28, 2008 7:36 PMHi all,
My EntityManager is null, and I'm pretty sure that I don't have something set right in my configurations. I'm trying to use hibernate as my context. I followed the reference pdf, but I still can't get it. Any help would be much appreciated.
Below are my components.xml, datasource, and hibernate.cfg.xml. If there is anything else that is needed, just say so and I'll post it.
components.xml
<?xml version="1.0" encoding="UTF-8"?> <components xmlns="http://jboss.com/products/seam/components" xmlns:core="http://jboss.com/products/seam/core" xmlns:persistence="http://jboss.com/products/seam/persistence" xmlns:drools="http://jboss.com/products/seam/drools" xmlns:bpm="http://jboss.com/products/seam/bpm" xmlns:security="http://jboss.com/products/seam/security" xmlns:mail="http://jboss.com/products/seam/mail" xmlns:transaction="http://jboss.com/products/seam/transaction" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.1.xsd http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.1.xsd http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.1.xsd http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.1.xsd http://jboss.com/products/seam/navigation http://jboss.com/products/seam/navigation-2.1.xsd"> <core:init debug="@debug@" jndi-pattern="@jndiPattern@"/> <core:manager concurrent-request-timeout="500" conversation-timeout="120000" conversation-id-parameter="cid" parent-conversation-id-parameter="pid"/> <transaction:ejb-transaction /> <persistence:hibernate-session-factory name="hibernateSessionFactory"/> <persistence:managed-hibernate-session name="registrationDatabase" auto-create="true" session-factory-jndi-name="java:/registrationDatabase"/> <factory name="session" scope="STATELESS" auto-create="true" value="#{entityManager.delegate}"/> </components>
datasource
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE datasources PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN" "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd"> <datasources> <local-tx-datasource> <jndi-name>testDatasource</jndi-name> <connection-url>jdbc:postgresql://localhost/registrationpage</connection-url> <driver-class>org.postgresql.Driver</driver-class> <user-name>username</user-name> <password>password</password> </local-tx-datasource> </datasources>
hibernate.cfg.xml
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory name="java:/registrationDatabase"> <property name="show_sql">false</property> <property name="connection.datasource">java:/testDatasource</property> <property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property> <property name="transaction.flush_before_completion">true</property> <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property> <mappings...../> </session-factory> </hibernate-configuration>