• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate and Container Managed Transaction

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In hibernate 2.1, what is the best way to get a hibernate working in a container managed environment. The hibernate document from the hibernate website tells to configure JTATransactionFactory in the hibernate.cfg.xml to work in a container managed environment.

But when I do that it works with JBoss but it fails in WebSphere because internally the factory tries to obtain the UserTransaction from the java:comp/UserTransaction which is the violation of the j2ee spec. It is not sure how come it worked in JBoss.

In Hibernate3.0 there is a transaction factory for CMT which is CMTTransactionFactory but what is the equivalent in hibernate2.1?

Here is the configuration used in the cfg.xml file
<property name="transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.WebSphereTransactionManagerLookup</property>


The transaction code is like this

Session ses = SessionFactory.openSession();
Transaction tx = ses.beginTransaction();
// do some insert/update
tx.commit();

Based on the document available in the hibernate website this is the idiom that is supposed to be worked in a managed and non-managed environment.

Any suggestions would be greatly appreciated.
 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to check the JNDI name in the configuration file, and in WebSphere management page, and make sure that they are equals.
 
Sethu Nambiar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JNDI lookup name and all other configurations are correct.
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<bean id="idofs" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${ jndi.datasource}" />
</bean>


in websphere use adminconsle to configure the websphere.
 
Sethu Nambiar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not using spring for Hibernate related work.
 
Ruth Stout was famous for gardening naked. Just like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic