Sweet!  Thanks!


14 jan 2010 kl. 06.46 skrev Clinton Begin:

It wouldn't be hard to change that, but first, the best thing might be to just write your own transaction manager that works... it's pretty easy. 

You can pass any class name in place of "MANAGED" in your configuration.

For example, here's the Managed connection implementation...

public class ManagedTransactionFactory implements TransactionFactory {
  public void setProperties(Properties props) {
  public Transaction newTransaction(Connection conn, boolean autoCommit) {
    return new ManagedTransaction(conn);

public class ManagedTransaction implements Transaction {
  private Connection connection;
  public ManagedTransaction(Connection connection) {
    this.connection = connection;
  public Connection getConnection() {
    return connection;
  public void commit() throws SQLException {
    // Does nothing
  public void rollback() throws SQLException {
    // Does nothing
  public void close() throws SQLException {
    // Does nothing

On Wed, Jan 13, 2010 at 10:28 PM, Stefan Hagström <stha721@gmail.com> wrote:
Hi, thanks!

Its a managed connection (CMT).
When using plain JBDC in an SLSB the jdbc connection is opened and closed in each method.
When closing a method it is not really closed but rather returned to the connection pool.

The container is afaik responsible for commit/rollback of the current transaction, not closing the "checked out"

Does this make sense? does anyone else got ibatis working with jboss 5.1?


2010/1/14 Clinton Begin <clinton.begin@gmail.com>

If it's a managed connection, it will not be closed, even if you call session.close().  The underlying container / transaction manager is responsible for closing it.  So the transaction scope for your SLSB should be opening and closing the connection.  Otherwise, change the transaction type to JDBC.


On Wed, Jan 13, 2010 at 2:43 PM, Stefan Hagström <stefan@iserv.se> wrote:


I'm new to Ibatis, and have tried to create a simple slsb as a dao with ibatis 3 with jboss 5. 

However it seems like connection are not closed/returned. Jboss is complaining about connections not beeing closed:

21:32:15,146 INFO  [CachedConnectionManager] Closing a connection for you.  Please close them yourself: org.jboss.resource.adapter.jdbc.jdk5.WrappedConnectionJDK5@8cffca
java.lang.Throwable: STACKTRACE

I've attached the configuration and slsb, any ideas?

<setting name="cacheEnabled" value="false"/> 
<setting name="lazyLoadingEnabled" value="false"/> 
    <typeAlias type="dto.valuecode.ValueCode" alias="ValueCode"/> 
  <environments default="prod"> 
       <environment id="prod"> 
       <transactionManager type="MANAGED">
       <dataSource type="JNDI">  
         <property name="data_source" value="java:/kalenderDB"/> 
    <mapper resource="META-INF/ValueCode.xml"/> 

public class ValueCodeDao implements ValueCodeDaoInterface {

SqlSessionFactory sqlSessionFactory=null

public void setup(){ 

System.out.println("Reading Ibatis configuration for ValueCodeDao");

String resource = "META-INF/ibatis.xml"
Reader reader;
try {
reader = Resources.getResourceAsReader(this.getClass().getClassLoader(),resource);
sqlSessionFactory =  new SqlSessionFactoryBuilder().build(reader); 

catch (IOException e) {



public int getNextValueCodeNumber(){

SqlSession session = sqlSessionFactory.openSession();

return 1;