-->
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.  [ 6 posts ] 
Author Message
 Post subject: Session not closing. JBoss closes for me. Huh?
PostPosted: Sun Jun 13, 2004 11:42 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2004 6:02 am
Posts: 46
Location: Kuala Lumpur, Malaysia
Context: Hibernate 2.1.2, JBoss 3.2.3

I'm getting this error
Code:
[net.sf.hibernate.engine.CacheSynchronization] transaction before completion callback
[org.jboss.resource.connectionmanager.CachedConnectionManager] Closing a connection for you. 
Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@db95a1
java.lang.Exception: STACKTRACE
        at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:282)
        at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:506)
        at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:814)
        at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:122)
        at net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:56)
        at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278)
        at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3264)
        at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3244)
        at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:61)
        at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:524)
        at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
        at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
        at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:906)

I'm using the same ThreadLocalSession code from this wiki item. The code below is extracted from a Session Bean method with CMT, transaction=required.
Code:
        ---o<--- code snipped for brevity ---

        try {
            session = HibernateSession.currentSession();
            tx = session.beginTransaction();                   

            // do some session.save here ...

            session.flush();
                       
        } catch(HibernateException he) {
            if (session.isConnected()) {
                try {
                    if (!tx.wasRolledBack())
                        tx.rollback();
                } catch (HibernateException he2) {
                    throw new EJBException(he);   
                }                       
            }
            throw new EJBException(he);
        } finally {
            HibernateSession.closeSession();
        } 

What am I doing wrong ? Thanks a lot.

Alistair[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 13, 2004 11:48 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2004 6:02 am
Posts: 46
Location: Kuala Lumpur, Malaysia
Just something to add to the previous post - Despite the error, my updates to the DB via hibernate is successfull.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 14, 2004 4:54 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
If you are using the HibernateJBossMBean and JTA/CMT, you do not need to manage the Hibernate transaction like you are doing. See:

http://www.hibernate.org/hib_docs/reference/en/html/manipulatingdata.html#manipulatingdata-endingsession-exceptions

Sherman


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 17, 2004 10:58 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2004 6:02 am
Posts: 46
Location: Kuala Lumpur, Malaysia
Thanks sgwood,

OK. I took out my usage of the Transaction API and I'm getting the same error.
The one thing to note is that I am only doing the session.save/session.updates etc.. inside a DAO class. Thus my session bean (with CMT) just delegates to the DAO. My DAO class is also doing a HibernateSession.currentSession().

thanks

alistair


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 18, 2004 8:24 am 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
Post the new code.

How are you doing the rollback?


Sherman


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 18, 2004 12:34 pm 
Newbie

Joined: Thu Apr 01, 2004 3:36 pm
Posts: 13
Location: New York
I had the same problem with Hibernate 2.1.2 and MSSQL. Hibernate 2.1.4 is OK.


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