-->
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: session closing early
PostPosted: Wed Nov 24, 2004 11:49 am 
Newbie

Joined: Thu Nov 04, 2004 1:37 pm
Posts: 10
i have followed the model given in the hibernate in action book for using hibernate in an mvc app. as in the dao gets a session and the filter closes the session. however, the session seems to be closing prior to the filter. i have an agent object that containts agents. in the struts action i can successfully get my agent object. then i put the agents into a new list and send it to the struts jsp where it is associated with a select options statement. this works until the lazy initialization attempts to kick in. the jsp says that there is no session. i am unsure as to how the session is being closed. here is a snippet of the debug output. - shane



session started in my struts action

DEBUG|2004-11-24|09:31:35.730|net.sf.hibernate.impl.SessionImpl.<init>(SessionImpl.java:555)|opened session
DEBUG|2004-11-24|09:31:35.740|net.sf.hibernate.transaction.JTATransaction.begin(JTATransaction.java:131)|Looking for UserTransaction under: javax.transaction.UserTransaction
DEBUG|2004-11-24|09:31:35.740|net.sf.hibernate.transaction.JTATransaction.begin(JTATransaction.java:143)|Obtained UserTransaction
DEBUG|2004-11-24|09:31:35.740|net.sf.hibernate.transaction.JTATransaction.begin(JTATransaction.java:148)|beginning new transaction
DEBUG|2004-11-24|09:31:35.740|net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2246)|flushing session
DEBUG|2004-11-24|09:31:35.750|net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2439)|Flushing entities and processing referenced collections
DEBUG|2004-11-24|09:31:35.750|net.sf.hibernate.impl.SessionImpl.flushCollections(SessionImpl.java:2780)|Processing unreferenced collections
DEBUG|2004-11-24|09:31:35.750|net.sf.hibernate.impl.SessionImpl.flushCollections(SessionImpl.java:2794)|Scheduling collection removes/(re)creates/updates
DEBUG|2004-11-24|09:31:35.750|net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2270)|Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
DEBUG|2004-11-24|09:31:35.750|net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2275)|Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
DEBUG|2004-11-24|09:31:35.750|net.sf.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1818)|Dont need to execute flush
DEBUG|2004-11-24|09:31:35.760|net.sf.hibernate.impl.BatcherImpl.logOpenPreparedStatement(BatcherImpl.java:200)|about to open: 0 open PreparedStatements, 0 open ResultSets
DEBUG|2004-11-24|09:31:35.760|net.sf.hibernate.impl.BatcherImpl.log(BatcherImpl.java:226)|select ....my select statement here.
DEBUG|2004-11-24|09:31:35.760|net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:249)|preparing statement
DEBUG|2004-11-24|09:31:35.770|net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:46)|binding '7984' to parameter: 1
DEBUG|2004-11-24|09:31:35.770|net.sf.hibernate.loader.Loader.doQuery(Loader.java:277)|processing result set
DEBUG|2004-11-24|09:31:35.770|net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)|returning '7984' as column: AGENCY_ID0_
DEBUG|2004-11-24|09:31:35.770|net.sf.hibernate.loader.Loader.getRow(Loader.java:480)|result row: 7984
DEBUG|2004-11-24|09:31:35.770|net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:611)|Initializing object from ResultSet: 7984
DEBUG|2004-11-24|09:31:35.780|net.sf.hibernate.loader.Loader.hydrate(Loader.java:680)|Hydrating entity: .Agency#7984

a bunch of nullable safe gets here. all good.

DEBUG|2004-11-24|09:31:35.820|net.sf.hibernate.loader.Loader.doQuery(Loader.java:294)|done processing result set (1 rows)
DEBUG|2004-11-24|09:31:35.820|net.sf.hibernate.impl.BatcherImpl.logClosePreparedStatement(BatcherImpl.java:207)|done closing: 0 open PreparedStatements, 0 open ResultSets
DEBUG|2004-11-24|09:31:35.820|net.sf.hibernate.impl.BatcherImpl.closePreparedStatement(BatcherImpl.java:269)|closing statement
DEBUG|2004-11-24|09:31:35.820|net.sf.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:314)|total objects hydrated: 1
DEBUG|2004-11-24|09:31:35.820|net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2202)|resolving associations for [Agency#7984]
DEBUG|2004-11-24|09:31:35.820|net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1986)|loading [Affiliate#2500]
DEBUG|2004-11-24|09:31:35.830|net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1986)|loading [Agent#10957]
DEBUG|2004-11-24|09:31:35.830|net.sf.hibernate.impl.SessionImpl.getCollection(SessionImpl.java:3933)|creating collection wrapper:[Agency.agents#7984]
DEBUG|2004-11-24|09:31:35.830|net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2226)|done materializing entity [Agency#7984]
DEBUG|2004-11-24|09:31:35.830|net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3116)|initializing non-lazy collections
DEBUG|2004-11-24|09:31:35.850|net.sf.hibernate.transaction.JTATransaction.commit(JTATransaction.java:50)|commit
DEBUG|2004-11-24|09:31:35.850|net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2246)|flushing session
DEBUG|2004-11-24|09:31:35.850|net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2439)|Flushing entities and processing referenced collections
DEBUG|2004-11-24|09:31:35.850|net.sf.hibernate.impl.SessionImpl.updateReachableCollection(SessionImpl.java:2884)|Collection found: [.Agency.agents#7984], was: [.Agency.agents#7984]
DEBUG|2004-11-24|09:31:35.850|net.sf.hibernate.impl.SessionImpl.flushCollections(SessionImpl.java:2780)|Processing unreferenced collections
DEBUG|2004-11-24|09:31:35.850|net.sf.hibernate.impl.SessionImpl.flushCollections(SessionImpl.java:2794)|Scheduling collection removes/(re)creates/updates
DEBUG|2004-11-24|09:31:35.850|net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2270)|Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
DEBUG|2004-11-24|09:31:35.850|net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2275)|Flushed: 0 (re)creations, 0 updates, 0 removals to 1 collections
DEBUG|2004-11-24|09:31:35.860|net.sf.hibernate.impl.Printer.toString(Printer.java:75)|listing entities:

my agency info listed ok here...

DEBUG|2004-11-24|09:31:35.860|net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2359)|executing flush
DEBUG|2004-11-24|09:31:35.860|net.sf.hibernate.impl.SessionImpl.postFlush(SessionImpl.java:2824)|post flush
DEBUG|2004-11-24|09:31:35.860|net.sf.hibernate.transaction.JTATransaction.commit(JTATransaction.java:55)|Committing UserTransaction started by Hibernate
DEBUG|2004-11-24|09:31:35.920|net.sf.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:585)|transaction completion
DEBUG|2004-11-24|09:31:35.930|net.sf.hibernate.impl.SessionImpl.close(SessionImpl.java:573)|closing session
DEBUG|2004-11-24|09:31:35.930|net.sf.hibernate.impl.SessionImpl.disconnect(SessionImpl.java:3336)|disconnecting session
DEBUG|2004-11-24|09:31:35.930|net.sf.hibernate.impl.BatcherImpl.closeConnection(BatcherImpl.java:302)|could not log warnings
java.sql.SQLException: The transaction is no longer active - status: 'Committed'. No further JDBC access is allowed within this transaction.
at weblogic.jdbc.wrapper.JTSConnection.checkIfRolledBack(JTSConnection.java:155)
at weblogic.jdbc.wrapper.JTSConnection.checkConnection(JTSConnection.java:164)
at weblogic.jdbc.wrapper.Connection.preInvocationHandler(Connection.java:77)
at weblogic.jdbc.wrapper.JTSConnection_weblogic_jdbc_oracle_OracleConnection.getWarnings(Unknown Source)
at net.sf.hibernate.impl.BatcherImpl.closeConnection(BatcherImpl.java:297)
at net.sf.hibernate.impl.SessionImpl.disconnect(SessionImpl.java:3352)
at net.sf.hibernate.impl.SessionImpl.close(SessionImpl.java:576)
at my.hibernate.HibernateSessionFactory.closeSession(HibernateSessionFactory.java:101)
at my.HibernateFilter.doFilter(HibernateFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:628)
at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:412)
at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:154)
at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:101)
at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:137)
at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:758)
at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:890)
at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:460)
at jsp_servlet._jsp.__mainlayout._jspService(mainLayout.jsp:37)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at my.HibernateFilter.doFilter(HibernateFilter.java:24)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:316)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:261)
at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:237)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:300)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at my.HibernateFilter.doFilter(HibernateFilter.java:24)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6458)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
DEBUG|2004-11-24|09:31:35.940|net.sf.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:585)|transaction completion

the struts jsp tries to lazy load the collection but the session was just closed

ERROR|2004-11-24|09:31:35.970|net.sf.hibernate.LazyInitializationException.<init>(LazyInitializationException.java:25)|Failed to lazily initialize a collection - no session or session was closed
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:209)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)
at net.sf.hibernate.collection.Set.iterator(Set.java:130)
at org.apache.struts.taglib.html.OptionsTag.getIterator(OptionsTag.java:396)
at org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:188)
at jsp_servlet._jsp.__start._jspService(start.jsp:29)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at my.HibernateFilter.doFilter(HibernateFilter.java:24)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:628)
at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:412)
at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:154)
at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:101)
at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:137)
at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:758)
at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:890)
at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:460)
at jsp_servlet._jsp.__mainlayout._jspService(mainLayout.jsp:46)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at my.HibernateFilter.doFilter(HibernateFilter.java:24)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:316)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:261)
at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:237)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:300)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at my.HibernateFilter.doFilter(HibernateFilter.java:24)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6458)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
DEBUG|2004-11-24|09:41:40.418|net.sf.hibernate.impl.SessionImpl.finalize(SessionImpl.java:3388)|running Session.finalize()


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 4:45 pm 
Newbie

Joined: Thu Nov 04, 2004 1:37 pm
Posts: 10
one ore thing: if i comment out the line in the filter that closes the session, everything works ok (albeit the session isnt closed). So, it appears to me that the filter is somehow being invoked prior to the jsp being rendered?


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.