-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: JTA outside a Session bean
PostPosted: Tue Nov 20, 2007 1:58 pm 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
Hi,
Does anyone know if it is possible to create an EntityManagerFactory if you can create EntityManager's that use JTA without using an EJB Session bean?

Can I do
Code:
EntityManagerFactory emf =
      Persistence.createEntityManagerFactory("ds");

In a normal java class for a persistence unit ds (for example)

Code:
<persistence-unit name="ds">
      <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>


Because when I try to do the following on JBoss I get the message:

Code:
javax.persistence.PersistenceException: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager
   org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:720)
   org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
   javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)


i.e. I am not allowed create the EntityManagerFactory referencing a persistence unit that uses JTA?

Any ideas?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 5:44 am 
Newbie

Joined: Mon Nov 19, 2007 12:40 pm
Posts: 2
Hi,

Try to set hibernate.transaction.manager_lookup_class
and hibernate.transaction.factory_class properties in persistence.xml.
I have also similiar problem but unfortunately I don't have any working
solution at the moment.

Regards,

Tomasz


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.