Please set <transactionManager....commitRequired="true">

More info is available in the following poorly titled wiki (my fault):

http://wiki.apache.org/ibatis/Database_20Specific_20Information

Clinton


On Fri, 28 Jan 2005 19:09:29 -0800 (PST), Mark Nabours
<[EMAIL PROTECTED]> wrote:
> 
> 
> Hello. 
> 
>   
> 
> We are currently developing our first application with iBATIS, and we are
> extremely impressed by its design and capabilities.  Everything was going
> great until we deployed our application to WAS 5.1 utilizing a JNDI
> datasource. 
> 
>   
> 
> We end up receiving the following exception: 
> 
> [1/28/05 20:31:45:954 CST] 796d3dfd WebGroup E SRVE0026E: [Servlet
> Error]-[LocalTransaction rolled-back due to setRollbackOnly]:
> com.ibm.ws.LocalTransaction.RolledbackException 
> 
>   
> 
> I've read the following post concerning issues with WebSphere: 
> 
> http://wiki.apache.org/ibatis/Database_20Specific_20Information 
> 
>   
> 
> But I'm afraid that we cannot implement the suggestions since we externally
> acquire a connection and pass it to the SqlMapClient.  Therefore, I'm not
> sure how or if we can set a transactionManager element within our
> configuration file since it requires a dataSource element as a child. 
> Currently, we do not have a transactionManager element at all.  
> 
>   
> 
> Here is the code we use to pass the connection (sorry about the formatting
> -- I'm using a web-based e-mail editor) : 
> 
>   
> 
> /** 
> 
> * Returns the cached <code>[EMAIL PROTECTED] SqlMapClient}</code> instance 
> for the
> DataSource alias. 
> 
> */ 
> 
> protected SqlMapClient getSqlMapClient(String dataSourceAlias) 
> 
> throws SQLException { 
>  
> 
> try { 
>  
> 
> SqlMapClient sqlMapClient = 
> 
> IBatisSqlMapService.getInstance().getSqlMapClient( 
> 
> dataSourceAlias); 
> 
> if (sqlMapClient.getCurrentConnection() == null) { 
> 
> //try to acquire a Connection from the abstract broker 
> 
> try { 
>  
> 
> Connection connection = 
> 
> getDatabaseConnection(dataSourceAlias); 
> 
> if (connection != null) { 
> 
> sqlMapClient.setUserConnection(connection); 
> 
> logger.debug( 
> 
> "Connection set via Common Services for \"" 
> 
> + dataSourceAlias 
> 
> + "\"."); 
> 
> } else { 
> 
> logger.debug( 
> 
> "Connection not configured via Common Services for \"" 
> 
> + dataSourceAlias 
> 
> + "\". Assuming iBatis will supply connection."); 
> 
> } 
> 
> } catch (SQLException e) { 
>  
> 
> logger.debug( 
> 
> "Connection not configured via Common Services for \"" 
> 
> + dataSourceAlias 
> 
> + "\". Assuming iBatis will supply connection."); 
> 
> } 
> 
> } 
> 
> return sqlMapClient; 
> 
> } catch (IOException e) { 
> 
> throw new Error(e); 
> 
> } 
> 
> } 
> 
>   
> 
> Also we "clean up" the application supplied user connection with the
> following code: 
> 
>   
> 
> /** 
> 
> * Clear out the <code>[EMAIL PROTECTED] Connection}</code> instanced stored 
> by this
> thread's 
> 
> * <code>[EMAIL PROTECTED] SqlMapClient}</code> instance keyed by
> <code>dataSourceName</code>. 
> 
> */ 
> 
> public void closeConnection(String dataSourceName) throws SQLException { 
> 
> try { 
> 
> //clear out user connection on sql map 
>  
> 
> SqlMapClient sqlMapClient = 
> 
> IBatisSqlMapService.getInstance().getSqlMapClient(dataSourceName); 
> 
> if (sqlMapClient != null) { 
>  
> 
> //explicitly commit transaction prior to close 
> 
> Connection connection = sqlMapClient.getCurrentConnection(); 
> 
> if (connection != null) { 
>  
> 
> //attempt to prevent exception -- didn't work 
> 
> connection.commit(); 
> 
> } 
> 
> sqlMapClient.setUserConnection(null); 
> 
> logger.debug( 
> 
> "The transaction for SqlMapClient \"" 
> 
> + dataSourceName 
> 
> + "\" has been cleared for calling thread."); 
> 
> } 
> 
> //close connection 
> 
> super.closeConnection(dataSourceName); 
> 
> } catch (IOException e) { 
>  
> 
> throw new Error(e.getMessage()); 
> 
> } 
> 
> } 
> 
>   
> 
> The IBatisSqlMapService is a singleton that caches SQLMapClients. 
> 
>   
> 
> I would appreciate any advice about how I could prevent the exception from
> occurring.  Does iBATIS take part in transactions even if the connection is
> supplied externally?  I'm also aware that the issue could be with our
> configuration of WebSphere, but I would like some ideas before I approach
> our WebSphere administrator. 
> 
>   
> 
> Thanks, 
> 
> Mark
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com

Reply via email to