-->
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: why jboss close connection (of Session) automatic
PostPosted: Sun Jan 18, 2004 4:41 am 
Newbie

Joined: Fri Oct 17, 2003 10:56 pm
Posts: 11
I deploy a sar in jboss according to Using Hibernate with JBoss .

My code in Session Bean :

Code:
public void update(Object obj) throws HibernateException {
   Session session = HibernateSession.currentSession();
   session.update(obj);
   session.flush
}


after run , JBoss throws an Exception

Code:
16:25:06,859 [Thread-7] DEBUG impl.SessionImpl                - post flush
16:25:06,859 [Thread-7] INFO  anager.CachedConnectionManager  - Successfully closed a connection for you.  Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@a53564
java.lang.Exception: Stack Trace
   at org.jboss.resource.connectionmanager.CachedConnectionManager.closeAll(CachedConnectionManager.java:376)
   at org.jboss.resource.connectionmanager.CachedConnectionManager.popMetaAwareObject(CachedConnectionManager.java:199)
   at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:190)
   at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
   at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
   at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
   at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
   at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)
   at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
   at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
   at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:322)
   at org.jboss.ejb.Container.invoke(Container.java:674)
   at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:353)
   at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:83)
.....


It close connection automatic but actually i don't want it to do so.

help....


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2004 5:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
If you are never closing your session, JBoss will close the connection (return it to the pool) at the end of your request. You have to close the session manually somewhere.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2004 4:48 pm 
Newbie

Joined: Wed Feb 25, 2004 10:24 am
Posts: 2
Location: boston
I ran into the same problem, and I actually do not want to close the connection, I have 2 queries in a row. And somehow JBoss close the connection after the first query, so the second query always fails.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 28, 2004 12:38 am 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
With session beans, you are in JTA land. A Hibernate session collaborates with JTA. Each top level method call into a SLSB is starting a JTA transaction, which is committed or rolled back. Your Hibernate session has to be flushed or rolled back before the JTA transaction finishes, otherwise you will get the stack traces you are seeing.

Have you folks checked out http://www.hibernate.org/168.html? I don't think that the ThreadLocal pattern works with session beans. Use the session per transaction pattern instead.


Sherman


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 28, 2004 12:43 am 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
sgwood wrote:
I don't think that the ThreadLocal pattern works with session beans.


Forget this. There are other folks using ThreadLocal with session beans.


Sherman


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 22, 2004 8:14 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Hi,

Check out this post:
http://forum.hibernate.org/viewtopic.php?t=77

and this may also be of help:
https://sourceforge.net/forum/forum.php ... _id=250340


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.