-->
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.  [ 7 posts ] 
Author Message
 Post subject: NON-JTA use of Hibernate with WebSphere
PostPosted: Wed Oct 12, 2005 3:13 am 
Newbie

Joined: Tue Mar 08, 2005 7:11 pm
Posts: 9
Location: Sydney, Australia
Several posts have touched on this issue, but from what I gather they all apply to those using JTA with Hibernate & WebSphere....

I'm trying get Hibernate to work with WebSphere, using a plain JDBC transaction factory. I'm using Hibernate in the EJB container, where the EJBs are just acting as facades, and my Hibernate sessions are being stored in ThreadLocals. I've had this issue with both WebSphere 5 and 6. I'm using Oracle 9i as my database.

I keep getting errors such as:
Code:
java.sql.SQLException: DSRA9350E: Operation Connection.commit is not allowed during a global transaction.


My transaction code is bog standard, as per "Hibernate In Action" book - simply beginTransaction(), do stuff, commit().

I can't understancd why I would be in a global transaction to begin with!

I've tried all sorts of Hibernate settings, but generally I'm using:
Code:
<property name="connection.datasource">MCIAWEBDS</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.jndi.class">com.ibm.websphere.naming.WsnInitialContextFactory</property>


There doesn't seem to be anything special to configure on the WebSphere datasources, but I've tried XA and non-XA, updating to the latest JDBC drivers, everything I can think of.

If anyone out there in user-land has Hibernate working in WebSphere in a non-JTA way (there must be some of you!) can you pretty pretty pleeeeeeaaaaase detail for me the settings you have used.

pllllllleeeeeeeeeeeaaaaaaaaaaasssseeeeeeee.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 4:09 am 
Beginner
Beginner

Joined: Thu Jun 30, 2005 4:20 am
Posts: 40
Location: Vienna
Hi,

I've never had this error so I can only guess, but maybe setting the EJB's Transaction type to Bean Managed would help... (if it is Container managed at the moment).

However, I recommend that you use JTA transactions anyway - why not use it when it is available?

regards
Stefan


Top
 Profile  
 
 Post subject: try by including this mapping
PostPosted: Wed Oct 12, 2005 6:13 pm 
Newbie

Joined: Wed Sep 07, 2005 5:11 pm
Posts: 4
<property name="hibernate.transaction.manager_lookup_class">net.sf.hibernate.transaction.WebSphereTransactionManagerLookup</property>

_________________
Pradeep


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 6:58 pm 
Newbie

Joined: Tue Mar 08, 2005 7:11 pm
Posts: 9
Location: Sydney, Australia
Thanks for the replies guys.

The hibernate.transaction.manager_lookup_class doesn't seem to help. Its seems like more of a JTA thing anyways.

I guess I can go and learn some more about JTA and use it, its just that we are bringing our code over from Weblogic and wanted it to run just as before. I wish I didn't have to use WebSphere... :(


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 7:27 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
"I'm trying get Hibernate to work with WebSphere, using a plain JDBC transaction factory. I'm using Hibernate in the EJB container, where the EJBs are just acting as facades, and my Hibernate sessions are being stored in ThreadLocals."

There are several significant mistakes in in this paragraph. First stop: http://hibernate.org/42.html - then follow the references and recommended documentation.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 9:54 pm 
Newbie

Joined: Tue Mar 08, 2005 7:11 pm
Posts: 9
Location: Sydney, Australia
In response to Christian's post:

Well, I've checked that out and I don't really see what is wrong with what I'm doing. There seems to be plenty of documentation saying that it can be done just the way that I am, and in fact i've had it running that way on Weblogic for quite a while.

Also, I've followed these instructions --> http://hibernate.org/173.html and still end up at the same point, with an error:
Code:
java.sql.SQLException: DSRA9350E: Operation setAutoCommit is not allowed during a global transaction.
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.setAutoCommit(WSJdbcConnection.java:2411)
at org.hibernate.transaction.JDBCTransaction.toggleAutoCommit(JDBCTransaction.java:174)
at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:122)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:95)
...


However, based those instructions I also tried setting the sharing scope to "Unshareable" to see what would happen and got:
Code:
WTRN0062E: An illegal attempt to use multiple resources that have only one-phase capability has occurred within a global transaction.


I must be missing something here in my understanding of how the datasource is being used - Why would it be "attempting to use multiple resources"?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 13, 2005 2:52 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
A datasource in a J2EE application server is per definition a JTA managed datasource. Your attempts to tread it like a JDBC connection fail.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.