[jboss-user] [EJB 3.0] - Problem instantiating an EntityManagerFactory

breako do-not-reply at jboss.com
Tue Nov 20 12:51:32 EST 2007


Hi,
I have configured a JTA datasource in my persistence.xml


  |    <persistence-unit name="h-source">
  | 	   <jta-data-source>java:DefaultDS</jta-data-source>
  |        <properties>	  
  |             <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
  |             <property name="hibernate.connection.username" value="sa"/>
  |             <property name="hibernate.connection.password" value=""/>
  |             <property name="hibernate.connection.url" value="jdbc:hsqldb:."/>
  |             <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
  |             <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
  |        </properties>
  |    </persistence-unit>
  | 

A simple JSP tries to look it up

  | EntityManagerFactory emf =
  | 		Persistence.createEntityManagerFactory("h-source");
  | 

I get the following:


  | org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager
  | 	org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:329)
  | 	org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
  | 	org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:713)
  | 	org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
  | 	javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
  | 	javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
  | 	org.apache.jsp.TestJTAWithJPA_jsp._jspService(TestJTAWithJPA_jsp.java:75)
  | 

Can I only use the EntityManagerFactory with JTA if I am inside a Session Bean?

Note the following link says so:
http://www.abcseo.com/tech/java/jboss-ebj-troubleshooting

anyone any ideas?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4106501#4106501

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4106501



More information about the jboss-user mailing list