Announcement Announcement Module
Collapse
No announcement yet.
ResultSet closed while using OpenSessionInViewInterceptor Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ResultSet closed while using OpenSessionInViewInterceptor

    Hello,

    I merged my domain related service layer and my domain classes using @Configurable which works fine for the most time.

    Now I added the OpenSessionInView interceptor to my web layer. Since I get on simple Session.get() calls these errors:

    Code:
    INFO: could not read column value from result set: dateCrea2_0_3_; Dieses ResultSet ist geschlossen.
    03.12.2007 14:04:31 org.hibernate.jdbc.AbstractBatcher closeQueryStatement
    WARNUNG: exception clearing maxRows/queryTimeout
    java.sql.SQLException: org.apache.commons.dbcp.DelegatingPreparedStatement with address: "select link0_.id as id0_3_, link0_1_.dateCreated as dateCrea2_0_3_, link0_1_.dateModified as dateModi3_0_3_, link0_1_.version as version0_3_, link0_1_.hidden as hidden0_3_, link0_1_.showEndDate as showEndD6_0_3_, link0_1_.showStartDate as showStar7_0_3_, link0_1_.sypnosis as sypnosis0_3_, link0_1_.title as title0_3_, link0_.url as url1_3_, link0_.useCount as useCount1_3_, tags1_.ContentElement_id as ContentE1_5_, tagreferen2_.id as tags2_5_, tagreferen2_.id as id6_0_, tagreferen2_.dateCreated as dateCrea2_6_0_, tagreferen2_.dateModified as dateModi3_6_0_, tagreferen2_.version as version6_0_, tagreferen2_.contentElement_id as contentE6_6_0_, tagreferen2_.tag_id as tag5_6_0_, contentele3_.id as id0_1_, contentele3_.dateCreated as dateCrea2_0_1_, contentele3_.dateModified as dateModi3_0_1_, contentele3_.version as version0_1_, contentele3_.hidden as hidden0_1_, contentele3_.showEndDate as showEndD6_0_1_, contentele3_.showStartDate as showStar7_0_1_, contentele3_.sypnosis as sypnosis0_1_, contentele3_.title as title0_1_, contentele3_1_.url as url1_1_, contentele3_1_.useCount as useCount1_1_, case when contentele3_1_.id is not null then 1 when contentele3_.id is not null then 0 end as clazz_1_, tag4_.id as id5_2_, tag4_.dateCreated as dateCrea2_5_2_, tag4_.dateModified as dateModi3_5_2_, tag4_.version as version5_2_, tag4_.name as name5_2_ from content.Link link0_ inner join content.ContentElement link0_1_ on link0_.id=link0_1_.id left outer join content.ContentElement_TagReference tags1_ on link0_.id=tags1_.ContentElement_id left outer join content.TagReference tagreferen2_ on tags1_.tags_id=tagreferen2_.id left outer join content.ContentElement contentele3_ on tagreferen2_.contentElement_id=contentele3_.id left outer join content.Link contentele3_1_ on contentele3_.id=contentele3_1_.id left outer join content.Tag tag4_ on tagreferen2_.tag_id=tag4_.id where link0_.id=380" is closed.
    	at org.apache.commons.dbcp.DelegatingStatement.checkOpen(DelegatingStatement.java:137)
    	at org.apache.commons.dbcp.DelegatingStatement.getMaxRows(DelegatingStatement.java:237)
    	at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:272)
    	at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:209)
    	at org.hibernate.loader.Loader.doQuery(Loader.java:714)
    	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
    	at org.hibernate.loader.Loader.loadEntity(Loader.java:1851)
    	at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
    	at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
    	at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2992)
    	at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
    	at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
    	at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
    	at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
    	at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
    	at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
    	at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
    	at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
    	at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:477)
    	at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
    	at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:471)
    	at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:465)
    	at info.ninan.hibernate.AbstractHibernateDAO.findById(AbstractHibernateDAO.java:45)
    	at info.ninan.controller.LinkController.bounce(LinkController.java:79)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:472)
    	at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:409)
    	at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
    	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:874)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
    	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:431)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    	at java.lang.Thread.run(Thread.java:613)
    03.12.2007 14:04:31 org.hibernate.util.JDBCExceptionReporter logExceptions
    WARNUNG: SQL Error: 0, SQLState: 08003
    03.12.2007 14:04:31 org.hibernate.util.JDBCExceptionReporter logExceptions
    SCHWERWIEGEND: Dieses ResultSet ist geschlossen.
    03.12.2007 14:04:31 org.hibernate.event.def.DefaultLoadEventListener onLoad
    It works again as I remove the interceptor from the HandlerMapping configuration.

    I use Spring 2.5.0 and Postgresql 8.2.

    Thank you in advance.

    Christian

  • #2
    Chicken-Eggīs-Fault

    Hi,

    finally I managed it myself. The problem was that the session factory wasnīt properly constructed when the Open Session In View Interceptor requested it. This was due to the instance of a @Configurable bean that depends itīs "own" DAO which in turn depends on the Session Factory.

    Since Hibernate creates instances of every Entity the @Configurable Aspect gets triggered and tries to create a DAO which tries to create a Session Factory which tries to create an Entity and so forth.

    I finally decoupled that stuff by introducing a lookup-method when getting the DAO. See. The following configuration:

    Code:
    <!-- LINK - start -->
    <bean name="linkDAO" class="info.ninan.link.HibernateLinkDAO">
    	<property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <bean class="info.ninan.link.Link" scope="prototype">
    	<lookup-method bean="linkDAO" name="getLinkDAO" />
    	<!-- <property name="linkDAO" ref="linkDAO" /> -->
    </bean>
    <!-- LINK - ende -->
    That works for me now. If someone things this is a bad idea please donīt hessiate to tell me.

    Best regards

    Christian

    Comment

    Working...
    X