1 Reply Latest reply on Nov 22, 2007 12:16 PM by waynebaylor

    Problem instantiating an EntityManagerFactory

    breako

      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?