-->
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.  [ 2 posts ] 
Author Message
 Post subject: ActionServlet and close session in hibernate
PostPosted: Fri Jan 27, 2006 8:34 am 
Newbie

Joined: Fri Jan 27, 2006 8:21 am
Posts: 1
Hibernate 3:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Oracle 10g:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

hi list,
i call method from my action struts class, i'm using tomcat 5.0.28:

Session session = HibernateSessionFactory.currentSession();
Transaction tx = session.beginTransaction();
session.save(myObject);
tx.commit();
session.close();

i insert my Object to DB successfully, but when i want to execute my forward in action struts i got the following displayed error on page, but
when i remove the line "session.close();" page is displayed successfully:
exception

javax.servlet.ServletException: Session is closed
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
...................

cause mère

org.hibernate.SessionException: Session is closed
org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:131)
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:49)
org.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:24)
org.hibernate.jdbc.JDBCContext.beginTransaction(JDBCContext.java:271)
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1079)
ma.co.omnidata.intranet.metier.service.referentiel.ServicesRefCommun.getBuList(ServicesRefCommun.java:47)
ma.co.omnidata.intranet.presentation.action.contrat.ContratInitAction.execute(ContratInitAction.java:41)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1062)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)


thanks

_________________
(it's not doubt who makes us crazy, but the fact to be sure)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 8:45 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
You could have found an answer by looking in the FAQ, in the manual or searching as this is a common problem.

Hibernate does not automatically intializes all related collections. If it would your complete database could be loaded in some cases as a collection can have a relation to a relation to a relation .....

Read in the reference chapter (performance and lazy initialisation) and in the wiki.
a)
initialize using a query
b)
open session in view pattern
c)
initialize by traversing your collections.

Sebastian

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


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