Announcement Announcement Module
Collapse
No announcement yet.
Sessions closing after commit Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sessions closing after commit

    Hi,

    I am using AppFuse / struts / spring 1.1.4 / Hibernate 2.1.7...

    I am saving an entity in my DAO layer (it is called from my struts action):

    method saveEntity()

    getHibernateTemplate().saveOrUpdate(entity);
    // Tried with this line commented out also
    getHibernateTemplate().flush();

    The spring transaction is setup as:

    <bean id="incidentDAOTarget" class="com.acompany.tracker.incidents.dao.hibernat e.IncidentsDAOHibernate">
    <property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>

    <bean id="incidentDAO"
    class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="target"><ref local="incidentDAOTarget"/></property>

    <property name="transactionManager"><ref local="transactionManager"/></property>

    <property name="transactionAttributes">
    <props>
    <prop key="save*">PROPAGATION_REQUIRED</prop>
    <prop key="remove*">PROPAGATION_REQUIRED</prop>
    </props>
    </property>

    </bean>




    I am getting a:

    net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed

    error when accessing a collection of an entity I have just saved...

    I am specifying lazy="true" in my Hibernate mapping file - from the trace it seems the session is open - but I still get the error..

    Any ideas? I thought the whole point of the OpenSessionInViewFilter was that is kept the session open?

    I even tried reloading my entity, after the save, but I still get the same error!!


    Full stack trace:

    21-03-05 09:55:29:165 - {INFO} actions.IncidentAction Thread [http-8080-Processor4]; Saving incident
    21-03-05 09:55:29:196 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Found thread-bound session [net.sf.hibernate.impl.SessionImpl@1d4616f] for Hibernate transaction
    21-03-05 09:55:29:196 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Using transaction object [org.springframework.orm.hibernate.HibernateTransac tionManager$HibernateTransactionObject@48d0c9]
    21-03-05 09:55:29:196 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Creating new transaction
    21-03-05 09:55:29:227 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Exposing Hibernate transaction as JDBC transaction [org.apache.commons.dbcp.PoolableConnection@157053a]
    21-03-05 09:55:29:227 - {DEBUG} hibernate.IncidentsDAOHibernate Thread [http-8080-Processor4]; session is [net.sf.hibernate.impl.SessionImpl@1d4616f]
    21-03-05 09:55:29:227 - {DEBUG} hibernate.IncidentsDAOHibernate Thread [http-8080-Processor4]; is connected is [true]
    21-03-05 09:55:29:227 - {DEBUG} hibernate.IncidentsDAOHibernate Thread [http-8080-Processor4]; is open is [true]
    21-03-05 09:55:29:227 - {DEBUG} hibernate.IncidentsDAOHibernate Thread [http-8080-Processor4]; is dirty is [false]
    21-03-05 09:55:29:227 - {DEBUG} hibernate.IncidentsDAOHibernate Thread [http-8080-Processor4]; flush mode is [AUTO]
    21-03-05 09:55:29:336 - {DEBUG} hibernate.IncidentsDAOHibernate Thread [http-8080-Processor4]; session is [net.sf.hibernate.impl.SessionImpl@1d4616f]
    21-03-05 09:55:29:336 - {DEBUG} hibernate.IncidentsDAOHibernate Thread [http-8080-Processor4]; is connected is [true]
    21-03-05 09:55:29:336 - {DEBUG} hibernate.IncidentsDAOHibernate Thread [http-8080-Processor4]; is open is [true]
    21-03-05 09:55:29:336 - {DEBUG} hibernate.IncidentsDAOHibernate Thread [http-8080-Processor4]; is dirty is [false]
    21-03-05 09:55:29:336 - {DEBUG} hibernate.IncidentsDAOHibernate Thread [http-8080-Processor4]; flush mode is [AUTO]
    21-03-05 09:55:29:336 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Triggering beforeCommit synchronization
    21-03-05 09:55:29:352 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Triggering beforeCompletion synchronization
    21-03-05 09:55:29:352 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Initiating transaction commit
    21-03-05 09:55:29:352 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Committing Hibernate transaction on session [net.sf.hibernate.impl.SessionImpl@1d4616f]
    21-03-05 09:55:29:352 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Triggering afterCompletion synchronization
    21-03-05 09:55:29:352 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Not closing pre-bound Hibernate session [net.sf.hibernate.impl.SessionImpl@1d4616f] after transaction
    21-03-05 09:55:29:352 - {INFO} actions.IncidentAction Thread [http-8080-Processor4]; Saved incident
    21-03-05 09:55:29:352 - {DEBUG} actions.IncidentAction Thread [http-8080-Processor4]; Calling ConvertUtil.convert
    21-03-05 09:55:29:368 - {DEBUG} actions.IncidentAction Thread [http-8080-Processor4]; returning bean with name [historyDAO]
    21-03-05 09:55:29:368 - {INFO} actions.IncidentAction Thread [http-8080-Processor4]; Saving history
    21-03-05 09:55:29:368 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Found thread-bound session [net.sf.hibernate.impl.SessionImpl@1d4616f] for Hibernate transaction
    21-03-05 09:55:29:368 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Using transaction object [org.springframework.orm.hibernate.HibernateTransac tionManager$HibernateTransactionObject@21840d]
    21-03-05 09:55:29:368 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Creating new transaction
    21-03-05 09:55:29:368 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Exposing Hibernate transaction as JDBC transaction [org.apache.commons.dbcp.PoolableConnection@157053a]
    21-03-05 09:55:29:383 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Triggering beforeCommit synchronization
    21-03-05 09:55:29:383 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Triggering beforeCompletion synchronization
    21-03-05 09:55:29:383 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Initiating transaction commit
    21-03-05 09:55:29:383 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Committing Hibernate transaction on session [net.sf.hibernate.impl.SessionImpl@1d4616f]
    21-03-05 09:55:29:399 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Triggering afterCompletion synchronization
    21-03-05 09:55:29:399 - {DEBUG} hibernate.HibernateTransactionManager Thread [http-8080-Processor4]; Not closing pre-bound Hibernate session [net.sf.hibernate.impl.SessionImpl@1d4616f] after transaction
    21-03-05 09:55:29:399 - {INFO} actions.IncidentAction Thread [http-8080-Processor4]; Saved history
    21-03-05 09:55:29:399 - {DEBUG} actions.IncidentAction Thread [http-8080-Processor4]; session is [net.sf.hibernate.impl.SessionImpl@1d4616f]
    21-03-05 09:55:29:399 - {DEBUG} actions.IncidentAction Thread [http-8080-Processor4]; is connected is [true]
    21-03-05 09:55:29:399 - {DEBUG} actions.IncidentAction Thread [http-8080-Processor4]; is open is [true]
    21-03-05 09:55:29:399 - {DEBUG} actions.IncidentAction Thread [http-8080-Processor4]; is dirty is [false]
    21-03-05 09:55:29:399 - {DEBUG} actions.IncidentAction Thread [http-8080-Processor4]; is dirty is [NEVER]
    21-03-05 09:55:29:399 - {DEBUG} actions.IncidentAction Thread [http-8080-Processor4]; Sending user '[email protected]' an MVIR e-mail
    21-03-05 09:55:31:680 - {DEBUG} fop.IncidentsXMLReader Thread [http-8080-Processor4]; Adding incident type as [null]
    21-03-05 09:55:31:680 - {ERROR} hibernate.LazyInitializationException Thread [http-8080-Processor4]; 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.i nitialize(PersistentCollection.java:209)
    at net.sf.hibernate.collection.PersistentCollection.r ead(PersistentCollection.java:71)
    at net.sf.hibernate.collection.Set.iterator(Set.java: 130)
    at com.acompany.tracker.fleet.pojo.FleetVehicle.getCu rrentSite(FleetVehicle.java:164)
    at com.acompany.tracker.incidents.fop.IncidentsXMLRea der.processFleetVehicles(IncidentsXMLReader.java:1 79)
    at com.acompany.tracker.incidents.fop.IncidentsXMLRea der.processIncident(IncidentsXMLReader.java:145)
    at com.acompany.tracker.incidents.fop.IncidentsXMLRea der.parse(IncidentsXMLReader.java:117)
    at com.acompany.tracker.incidents.fop.IncidentsXMLRea der.parse(IncidentsXMLReader.java:92)
    at org.apache.xml.dtm.ref.DTMManagerDefault.getDTM(DT MManagerDefault.java:495)
    at org.apache.xalan.transformer.TransformerImpl.trans form(TransformerImpl.java:658)
    at org.apache.xalan.transformer.TransformerImpl.trans form(TransformerImpl.java:1129)
    at org.apache.xalan.transformer.TransformerImpl.trans form(TransformerImpl.java:1107)
Working...
X