-->
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.  [ 3 posts ] 
Author Message
 Post subject: Unable to call rollback with Hibernate 2.1.6 and Websphere 6
PostPosted: Wed Jul 19, 2006 8:47 am 
Newbie

Joined: Wed Jul 19, 2006 8:37 am
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

First: Yes I have read the FAQ on rollbacks and WAS. However, I am most definitely calling connection.setAutoCommit(false) on any connection to my transactional datasource inside of Websphere. I tried to post this on Developer works, but the answer I received was stop using Hibernate and use some IBM solution. This is not possible since the application I am working with is very large. The code works fine in Weblogic 7.x. All of the hibernate mappings and all objects are persisting in the Websphere version however if we ever call rollback() we get a StaleConnectionException. It as simple as:
//Please pardon my pseudo code
Connection conn = dataSource.getConnection()
conn.setAutoCommit(false);
hibernateSession.begin();
System.out.println("Hi I am inside a transaction");
hibernateSession.rollback(); //CRASH!

If I catch the exception the program works fine but we would really like to rollback the transaction in case anyone has tried to save anything.

I am using Hibernate 2.1.6 and WAS 6.2.11. I have a Web application that uses Hibernate's JDBCTransaction class. Before we make an update we call

public void startTransaction()
throws WesComException
{
try
{ ///This calls JDBCTransaction.begin()
transaction = hibernateSession.beginTransaction();
}
catch(Exception e)
{
AuditServiceDelegate.fireEvent(new ExceptionAuditEvent(e));
throw new WesComException(e);
}
}

When we realize we don't want to go through with the transaction we call.

public void rollbackTransaction()
throws WesComException
{
try
{
//This calls JDBCTransaction.rollback();
transaction.rollback();
}
catch(Exception e)
{
AuditServiceDelegate.fireEvent(new ExceptionAuditEvent(e));
throw new WesComException(e);
}
}

Evertime this happens we get this exception:

.
[7/17/06 15:05:25:815 EDT] 0000006e ConnectionEve A J2CA0056I: The Connection Manager received a fatal connection error from the Resource Adaptor for resource txWesComDataSource. The exception which was received is com.ibm.websphere.ce.cm.StaleConnectionException: A communication error has been detected. Communication protocol being used: Reply.fill(). Communication API being used: InputStream.read(). Location where the error was detected: insufficient data. Communication function detecting the error: *. Protocol specific error codes(s) TCP/IP SOCKETS
[7/17/06 15:05:25:846 EDT] 0000006e JDBCTransacti E net.sf.hibernate.transaction.JDBCTransaction rollback Rollback failed
com.ibm.websphere.ce.cm.StaleConnectionException: A communication error has been detected. Communication protocol being used: Reply.fill(). Communication API being used: InputStream.read(). Location where the error was detected: insufficient data. Communication function detecting the error: *. Protocol specific error codes(s) TCP/IP SOCKETS
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java(Compiled Code))
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java(Compiled Code))
at java.lang.reflect.Constructor.newInstance(Constructor.java(Compiled Code))
at com.ibm.websphere.rsadapter.GenericDataStoreHelper.mapExceptionHelper(GenericDataStoreHelper.java:502)
at com.ibm.websphere.rsadapter.GenericDataStoreHelper.mapException(GenericDataStoreHelper.java:545)
at com.ibm.ws.rsadapter.jdbc.WSJdbcUtil.mapException(WSJdbcUtil.java:902)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.rollback(WSJdbcConnection.java:2385)
at net.sf.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:86)
at com.westfieldgrp.wescom.framework.model.dao.hibernate.AbstractHibernateDataAccessObjectFactory.rollbackTransaction(AbstractHibernateDataAccessObjectFactory.java:148)
at com.westfieldgrp.wescom.framework.command.CommandKernel.update(CommandKernel.java:450)
at com.westfieldgrp.wescom.service.command.SLSBCommandServiceBean.update(SLSBCommandServiceBean.java:121)
at com.westfieldgrp.wescom.service.command.EJSRemoteStatelessCommandService_0bb7e8f9.update(EJSRemoteStatelessCommandService_0bb7e8f9.java:102)
at com.westfieldgrp.wescom.service.command._SLSBCommandService_Stub.update(_SLSBCommandService_Stub.java:359)
at com.westfieldgrp.wescom.service.command.CommandServiceDelegate.update(CommandServiceDelegate.java:263)
at com.westfieldgrp.wescom.cl.ui.action.CommercialBaseAction.doWork(CommercialBaseAction.java:249)
at com.westfieldgrp.wescom.cl.ui.action.BasicInformationAction.doWork(BasicInformationAction.java:80)


We are using Type 4 XA IBM JDBC drivers. No Runtime exceptions are being thrown we are simply testing for an invalid case in our business code and rolling back. In this particular case commit is NOT being called. The database is DB2 7.2.x. If I catch the StaleConnectionException then everything works fine because like I said there really is no transaction to rollback, but we shouldn't get the exception. Also, we are calling connection.setAutoCommit(false) before we start the transaction.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 19, 2006 8:48 am 
Newbie

Joined: Wed Jul 19, 2006 8:37 am
Posts: 3
Also, there autoCommit is no longer an attribute of a dataSource in WAS 6.x, atleast for the XA IBM drivers we are using. You cannot even set it as a custom property inside the console.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 24, 2006 10:36 am 
Newbie

Joined: Wed Jul 19, 2006 8:37 am
Posts: 3
I am still having this problem and I was wondering if anyone else was using Hibernate 2.1.6 with Websphere 6.0.


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