Announcement Announcement Module
Collapse
No announcement yet.
no session or session was closed (again) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • no session or session was closed (again)

    hello everybody

    i don't know what to do furthermore to fix the error -
    "no session or session was closed"

    here my web.xml

    <filter>
    <filter-name>hibernateFilter</filter-name>
    <filter-class>org.springframework.orm.hibernate.support.Op enSessionInViewFilter</filter-class>

    </filter>

    <filter-mapping>
    <filter-name>hibernateFilter</filter-name>
    <url-pattern>*.do</url-pattern>
    </filter-mapping>

    <listener>
    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
    </listener>


    here my MetaDaten.hbm.xml file:


    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

    <hibernate-mapping>

    <class name="at.univie.auv.redbaron.model.MetaGruppen" table="META_GRUPPEN">
    <meta attribute="class-description">
    @author ZAL
    </meta>

    <id name="tid" column="TID">
    <generator class="at.univie.auv.util.hibernate.TidGenerator">
    <param name="table">META_GRUPPEN</param>
    </generator>
    </id>

    <property name="i3vUserId" column="I3V_USER_ID" type="double" not-null="false"/>

    <property name="i3vDate" column="I3V_DATE" type="string" not-null="false"/>

    <property name="name" column="Name" type="string" not-null="false"/>

    <many-to-one name="application" column="I3V_FILE_ID"
    class="at.univie.auv.redbaron.model.I3VFile"
    insert="true" update="true" cascade="all" />

    <many-to-one name="displayType" column="META_DARSTELLUNG_TYP_ID"
    class="at.univie.auv.redbaron.model.MetaDarstellun gstyp"
    insert="true" update="true" cascade="all"/>

    <set name="metaGruppenSprache" lazy="true" cascade="all">
    <key column="RELATION"/>
    <one-to-many class="at.univie.auv.redbaron.model.MetaGruppenSpr ache" />
    </set>

    <set name="keys" table="META_GRUPPEUNTEROBER_HBEZ" lazy="true" cascade="all">
    <key column="META_GRUPPEN_ID"/>
    <many-to-many column="META_GRUPPEN_ID2"
    class="at.univie.auv.redbaron.model.MetaGruppen"/>
    </set>

    </class>

    <query name="getPagesByApplication">
    <![CDATA[from MetaGruppen as gruppe
    where gruppe.application.tid = :tid
    and gruppe.displayType.code = :typeName ]]>
    </query>

    <query name="getKeysByPage">
    <![CDATA[from MetaGruppen as gruppe
    where gruppe.application.tid = :tid
    and gruppe.displayType.code = :typeName
    and gruppe.tid = ageTid ]]>
    </query>

    </hibernate-mapping>

    the action only trys to load data based on the last query "getKeysByPage"

    the only thing i get is that lazy init could not be performed - without lazy it works ...
    what i'm doing wrong? any help is appreciated

    thanx in advance

    greetinx

    tuor

  • #2
    follow up: error message

    seems to be that openinViewFilter works - maybe the whole construct isn't
    set up very smart - any hints?

    thanx

    tuor

    2004-09-20 15:13:25,791 [org.springframework.orm.hibernate.support.OpenSess ionInViewFilter] DEBUG - Closing single Hibernate session in OpenSessionInViewFilter
    2004-09-20 15:13:25,791 [org.springframework.orm.hibernate.support.OpenSess ionInViewFilter] DEBUG - Closing single Hibernate session in OpenSessionInViewFilter
    2004-09-20 15:13:25,791 [org.springframework.orm.hibernate.SessionFactoryUt ils] DEBUG - Closing Hibernate session
    2004-09-20 15:13:25,791 [org.springframework.orm.hibernate.SessionFactoryUt ils] DEBUG - Closing Hibernate session
    2004-09-20 15:14:50,453 [org.springframework.orm.hibernate.support.OpenSess ionInViewFilter] DEBUG - Using session factory 'sessionFactory' for OpenSessionInViewFilter
    2004-09-20 15:14:50,453 [org.springframework.orm.hibernate.support.OpenSess ionInViewFilter] DEBUG - Using session factory 'sessionFactory' for OpenSessionInViewFilter
    2004-09-20 15:14:50,453 [org.springframework.beans.factory.support.Abstract BeanFactory] DEBUG - Returning cached instance of singleton bean 'sessionFactory'
    2004-09-20 15:14:50,453 [org.springframework.beans.factory.support.Abstract BeanFactory] DEBUG - Returning cached instance of singleton bean 'sessionFactory'
    2004-09-20 15:14:50,453 [org.springframework.beans.factory.support.Abstract BeanFactory] DEBUG - Bean with name 'sessionFactory' is a factory bean
    2004-09-20 15:14:50,453 [org.springframework.beans.factory.support.Abstract BeanFactory] DEBUG - Bean with name 'sessionFactory' is a factory bean
    2004-09-20 15:14:50,453 [org.springframework.orm.hibernate.support.OpenSess ionInViewFilter] DEBUG - Opening single Hibernate session in OpenSessionInViewFilter
    2004-09-20 15:14:50,453 [org.springframework.orm.hibernate.support.OpenSess ionInViewFilter] DEBUG - Opening single Hibernate session in OpenSessionInViewFilter
    2004-09-20 15:14:50,453 [org.springframework.orm.hibernate.SessionFactoryUt ils] DEBUG - Opening Hibernate session
    2004-09-20 15:14:50,453 [org.springframework.orm.hibernate.SessionFactoryUt ils] DEBUG - Opening Hibernate session
    2004-09-20 15:14:50,453 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Bound value [[email protected] f465] for key [[email protected]] to thread [http-8080-Processor23]
    2004-09-20 15:14:50,453 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Bound value [[email protected] f465] for key [[email protected]] to thread [http-8080-Processor23]
    2004-09-20 15:14:50,453 [org.springframework.web.struts.DelegatingActionUti ls] DEBUG - DelegatingActionProxy with mapping path '/groups' and module prefix '' delegating to Spring bean with name [/groups]
    2004-09-20 15:14:50,453 [org.springframework.web.struts.DelegatingActionUti ls] DEBUG - DelegatingActionProxy with mapping path '/groups' and module prefix '' delegating to Spring bean with name [/groups]
    2004-09-20 15:14:50,453 [org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory] DEBUG - Creating instance of bean '/groups' with merged definition [Root bean with class [at.univie.auv.redbaron.actions.MetaGroups] defined in resource [/WEB-INF/action-servlet.xml] of ServletContext]
    2004-09-20 15:14:50,453 [org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory] DEBUG - Creating instance of bean '/groups' with merged definition [Root bean with class [at.univie.auv.redbaron.actions.MetaGroups] defined in resource [/WEB-INF/action-servlet.xml] of ServletContext]
    2004-09-20 15:14:50,463 [org.springframework.beans.CachedIntrospectionResul ts] DEBUG - Getting BeanInfo for class [at.univie.auv.redbaron.actions.MetaGroups]
    2004-09-20 15:14:50,463 [org.springframework.beans.CachedIntrospectionResul ts] DEBUG - Getting BeanInfo for class [at.univie.auv.redbaron.actions.MetaGroups]
    2004-09-20 15:14:50,503 [org.springframework.beans.CachedIntrospectionResul ts] DEBUG - Caching PropertyDescriptors for class [at.univie.auv.redbaron.actions.MetaGroups]
    2004-09-20 15:14:50,503 [org.springframework.beans.CachedIntrospectionResul ts] DEBUG - Caching PropertyDescriptors for class [at.univie.auv.redbaron.actions.MetaGroups]
    2004-09-20 15:14:50,503 [org.springframework.beans.CachedIntrospectionResul ts] DEBUG - Found property 'class' of type [class java.lang.Class]; editor=[null]
    2004-09-20 15:14:50,503 [org.springframework.beans.CachedIntrospectionResul ts] DEBUG - Found property 'class' of type [class java.lang.Class]; editor=[null]
    2004-09-20 15:14:50,503 [org.springframework.beans.CachedIntrospectionResul ts] DEBUG - Found property 'groups' of type [interface at.univie.auv.redbaron.services.MetaGruppenService]; editor=[null]
    2004-09-20 15:14:50,503 [org.springframework.beans.CachedIntrospectionResul ts] DEBUG - Found property 'groups' of type [interface at.univie.auv.redbaron.services.MetaGruppenService]; editor=[null]
    2004-09-20 15:14:50,513 [org.springframework.beans.CachedIntrospectionResul ts] DEBUG - Found property 'servlet' of type [class org.apache.struts.action.ActionServlet]; editor=[null]
    2004-09-20 15:14:50,513 [org.springframework.beans.CachedIntrospectionResul ts] DEBUG - Found property 'servlet' of type [class org.apache.struts.action.ActionServlet]; editor=[null]
    2004-09-20 15:14:50,523 [org.springframework.beans.CachedIntrospectionResul ts] DEBUG - Class [at.univie.auv.redbaron.actions.MetaGroups] is cache-safe
    2004-09-20 15:14:50,523 [org.springframework.beans.CachedIntrospectionResul ts] DEBUG - Class [at.univie.auv.redbaron.actions.MetaGroups] is cache-safe
    2004-09-20 15:14:50,523 [org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory] DEBUG - Resolving reference from property 'groups' in bean '/groups' to bean 'groupManager'
    2004-09-20 15:14:50,523 [org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory] DEBUG - Resolving reference from property 'groups' in bean '/groups' to bean 'groupManager'
    2004-09-20 15:14:50,523 [org.springframework.beans.factory.support.Abstract BeanFactory] DEBUG - Returning cached instance of singleton bean 'groupManager'
    2004-09-20 15:14:50,523 [org.springframework.beans.factory.support.Abstract BeanFactory] DEBUG - Returning cached instance of singleton bean 'groupManager'
    2004-09-20 15:14:50,523 [org.springframework.beans.factory.support.Abstract BeanFactory] DEBUG - Bean with name 'groupManager' is a factory bean
    2004-09-20 15:14:50,523 [org.springframework.beans.factory.support.Abstract BeanFactory] DEBUG - Bean with name 'groupManager' is a factory bean
    2004-09-20 15:14:50,523 [org.springframework.beans.BeanWrapperImpl] DEBUG - About to invoke write method [public void at.univie.auv.redbaron.actions.MetaGroups.setGroup s(at.univie.auv.redbaron.services.MetaGruppenServi ce)] on object of class [at.univie.auv.redbaron.actions.MetaGroups]
    2004-09-20 15:14:50,523 [org.springframework.beans.BeanWrapperImpl] DEBUG - About to invoke write method [public void at.univie.auv.redbaron.actions.MetaGroups.setGroup s(at.univie.auv.redbaron.services.MetaGruppenServi ce)] on object of class [at.univie.auv.redbaron.actions.MetaGroups]
    2004-09-20 15:14:50,523 [org.springframework.beans.BeanWrapperImpl] DEBUG - Invoked write method [public void at.univie.auv.redbaron.actions.MetaGroups.setGroup s(at.univie.auv.redbaron.services.MetaGruppenServi ce)] with value of type [at.univie.auv.redbaron.services.MetaGruppenService]
    2004-09-20 15:14:50,523 [org.springframework.beans.BeanWrapperImpl] DEBUG - Invoked write method [public void at.univie.auv.redbaron.actions.MetaGroups.setGroup s(at.univie.auv.redbaron.services.MetaGruppenServi ce)] with value of type [at.univie.auv.redbaron.services.MetaGruppenService]
    2004-09-20 15:14:50,533 [org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory] DEBUG - Invoking BeanPostProcessors before initialization of bean '/groups'
    2004-09-20 15:14:50,533 [org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory] DEBUG - Invoking BeanPostProcessors before initialization of bean '/groups'
    2004-09-20 15:14:50,533 [org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory] DEBUG - Invoking BeanPostProcessors after initialization of bean '/groups'
    2004-09-20 15:14:50,533 [org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory] DEBUG - Invoking BeanPostProcessors after initialization of bean '/groups'
    2004-09-20 15:14:50,533 [org.springframework.transaction.interceptor.Transa ctionAspectSupport] DEBUG - Getting transaction for method 'loadKeys' in class [at.univie.auv.redbaron.services.MetaGruppenService]
    2004-09-20 15:14:50,533 [org.springframework.transaction.interceptor.Transa ctionAspectSupport] DEBUG - Getting transaction for method 'loadKeys' in class [at.univie.auv.redbaron.services.MetaGruppenService]
    2004-09-20 15:14:50,533 [org.springframework.transaction.support.AbstractPl atformTransactionManager] DEBUG - Using transaction object [org.springframework.orm.hibernate.HibernateTransac [email protected]]
    2004-09-20 15:14:50,533 [org.springframework.transaction.support.AbstractPl atformTransactionManager] DEBUG - Using transaction object [org.springframework.orm.hibernate.HibernateTransac [email protected]]
    2004-09-20 15:14:50,533 [org.springframework.transaction.support.AbstractPl atformTransactionManager] DEBUG - Creating new transaction
    2004-09-20 15:14:50,533 [org.springframework.transaction.support.AbstractPl atformTransactionManager] DEBUG - Creating new transaction
    2004-09-20 15:14:50,533 [org.springframework.orm.hibernate.SessionFactoryUt ils] DEBUG - Opening Hibernate session
    2004-09-20 15:14:50,533 [org.springframework.orm.hibernate.SessionFactoryUt ils] DEBUG - Opening Hibernate session
    2004-09-20 15:14:50,533 [org.springframework.orm.hibernate.HibernateTransac tionManager] DEBUG - Opened new session [[email protected]] for Hibernate transaction
    2004-09-20 15:14:50,533 [org.springframework.orm.hibernate.HibernateTransac tionManager] DEBUG - Opened new session [[email protected]] for Hibernate transaction
    2004-09-20 15:14:50,543 [org.springframework.jdbc.datasource.DriverManagerD ataSource] DEBUG - Creating new JDBC connection to [jdbc:oracle:thin:@univis4.uv.univie.ac.at:1521:ent w]
    2004-09-20 15:14:50,543 [org.springframework.jdbc.datasource.DriverManagerD ataSource] DEBUG - Creating new JDBC connection to [jdbc:oracle:thin:@univis4.uv.univie.ac.at:1521:ent w]
    2004-09-20 15:14:50,713 [org.springframework.jdbc.datasource.DataSourceUtil s] DEBUG - Setting JDBC connection [[email protected]] read-only
    2004-09-20 15:14:50,713 [org.springframework.jdbc.datasource.DataSourceUtil s] DEBUG - Setting JDBC connection [[email protected]] read-only
    2004-09-20 15:14:50,743 [org.springframework.orm.hibernate.HibernateTransac tionManager] DEBUG - Exposing Hibernate transaction as JDBC transaction [[email protected]]
    2004-09-20 15:14:50,743 [org.springframework.orm.hibernate.HibernateTransac tionManager] DEBUG - Exposing Hibernate transaction as JDBC transaction [[email protected]]
    2004-09-20 15:14:50,743 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Bound value [org.springframework.jdbc.datasource.ConnectionHold [email protected]] for key [org.springframework.jdbc.datasource.DriverManagerD [email protected]] to thread [http-8080-Processor23]
    2004-09-20 15:14:50,743 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Bound value [org.springframework.jdbc.datasource.ConnectionHold [email protected]] for key [org.springframework.jdbc.datasource.DriverManagerD [email protected]] to thread [http-8080-Processor23]
    2004-09-20 15:14:50,743 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Bound value [[email protected] dc55f] for key [[email protected]] to thread [http-8080-Processor23]
    2004-09-20 15:14:50,743 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Bound value [[email protected] dc55f] for key [[email protected]] to thread [http-8080-Processor23]
    2004-09-20 15:14:50,743 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Initializing transaction synchronization
    2004-09-20 15:14:50,743 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Initializing transaction synchronization
    2004-09-20 15:14:50,743 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Retrieved value [[email protected] dc55f] for key [[email protected]] bound to thread [http-8080-Processor23]
    2004-09-20 15:14:50,743 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Retrieved value [[email protected] dc55f] for key [[email protected]] bound to thread [http-8080-Processor23]
    2004-09-20 15:14:50,753 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Retrieved value [[email protected] dc55f] for key [[email protected]] bound to thread [http-8080-Processor23]
    2004-09-20 15:14:50,753 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Retrieved value [[email protected] dc55f] for key [[email protected]] bound to thread [http-8080-Processor23]
    2004-09-20 15:14:50,943 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Retrieved value [[email protected] dc55f] for key [[email protected]] bound to thread [http-8080-Processor23]
    2004-09-20 15:14:50,943 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Retrieved value [[email protected] dc55f] for key [[email protected]] bound to thread [http-8080-Processor23]
    2004-09-20 15:14:50,943 [org.springframework.transaction.interceptor.Transa ctionAspectSupport] DEBUG - Invoking commit for transaction on method 'loadKeys' in class [at.univie.auv.redbaron.services.MetaGruppenService]
    2004-09-20 15:14:50,943 [org.springframework.transaction.interceptor.Transa ctionAspectSupport] DEBUG - Invoking commit for transaction on method 'loadKeys' in class [at.univie.auv.redbaron.services.MetaGruppenService]
    2004-09-20 15:14:50,943 [org.springframework.transaction.support.AbstractPl atformTransactionManager] DEBUG - Triggering beforeCommit synchronization
    2004-09-20 15:14:50,943 [org.springframework.transaction.support.AbstractPl atformTransactionManager] DEBUG - Triggering beforeCommit synchronization
    2004-09-20 15:14:50,953 [org.springframework.transaction.support.AbstractPl atformTransactionManager] DEBUG - Triggering beforeCompletion synchronization
    2004-09-20 15:14:50,953 [org.springframework.transaction.support.AbstractPl atformTransactionManager] DEBUG - Triggering beforeCompletion synchronization
    2004-09-20 15:14:50,953 [org.springframework.transaction.support.AbstractPl atformTransactionManager] DEBUG - Initiating transaction commit
    2004-09-20 15:14:50,953 [org.springframework.transaction.support.AbstractPl atformTransactionManager] DEBUG - Initiating transaction commit
    2004-09-20 15:14:50,963 [org.springframework.orm.hibernate.HibernateTransac tionManager] DEBUG - Committing Hibernate transaction on session [[email protected]]
    2004-09-20 15:14:50,963 [org.springframework.orm.hibernate.HibernateTransac tionManager] DEBUG - Committing Hibernate transaction on session [[email protected]]
    2004-09-20 15:14:50,973 [org.springframework.transaction.support.AbstractPl atformTransactionManager] DEBUG - Triggering afterCompletion synchronization
    2004-09-20 15:14:50,973 [org.springframework.transaction.support.AbstractPl atformTransactionManager] DEBUG - Triggering afterCompletion synchronization
    2004-09-20 15:14:50,973 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Clearing transaction synchronization
    2004-09-20 15:14:50,973 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Clearing transaction synchronization
    2004-09-20 15:14:50,973 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Removed value [[email protected] dc55f] for key [[email protected]] from thread [http-8080-Processor23]
    2004-09-20 15:14:50,973 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Removed value [[email protected] dc55f] for key [[email protected]] from thread [http-8080-Processor23]
    2004-09-20 15:14:50,973 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Removed value [org.springframework.jdbc.datasource.ConnectionHold [email protected]] for key [org.springframework.jdbc.datasource.DriverManagerD [email protected]] from thread [http-8080-Processor23]
    2004-09-20 15:14:50,973 [org.springframework.transaction.support.Transactio nSynchronizationManager] DEBUG - Removed value [org.springframework.jdbc.datasource.ConnectionHold [email protected]] for key [org.springframework.jdbc.datasource.DriverManagerD [email protected]] from thread [http-8080-Processor23]
    2004-09-20 15:14:50,973 [org.springframework.jdbc.datasource.DataSourceUtil s] DEBUG - Resetting read-only flag of connection [[email protected]]
    2004-09-20 15:14:50,973 [org.springframework.jdbc.datasource.DataSourceUtil s] DEBUG - Resetting read-only flag of connection [[email protected]]
    2004-09-20 15:14:50,983 [org.springframework.orm.hibernate.HibernateTransac tionManager] DEBUG - Closing Hibernate session [[email protected]] after transaction
    2004-09-20 15:14:50,983 [org.springframework.orm.hibernate.HibernateTransac tionManager] DEBUG - Closing Hibernate session [[email protected]] after transaction
    2004-09-20 15:14:50,983 [org.springframework.orm.hibernate.SessionFactoryUt ils] DEBUG - Closing Hibernate session
    2004-09-20 15:14:50,983 [org.springframework.orm.hibernate.SessionFactoryUt ils] DEBUG - Closing Hibernate session
    2004-09-20 15:14:51,084 [net.sf.hibernate.LazyInitializationException] ERROR - 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)

    Comment


    • #3
      ... solved it

      hello everbody

      after trying out a lot of approaches without any success we found the solution in the "petstore" example, delivered with the spring package.

      look at this and you will be as happy as we are now ;-)

      Code:
      public abstract class BaseAction extends Action &#123;
      
        private PetStoreFacade petStore;
      
      	public void setServlet&#40;ActionServlet actionServlet&#41; &#123;
      		super.setServlet&#40;actionServlet&#41;;
      		ServletContext servletContext = actionServlet.getServletContext&#40;&#41;;
      		WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext&#40;servletContext&#41;;
      		this.petStore = &#40;PetStoreFacade&#41; wac.getBean&#40;"petStore"&#41;;
      	&#125;
      
      	protected PetStoreFacade getPetStore&#40;&#41; &#123;
      		return petStore;
      	&#125;
      
      &#125;
      greetinx

      tuor

      Comment


      • #4
        hi

        when working with struts a possible solution can be to remove the
        "applicationContext.xml" from the plug-in config in your struts-config.xml

        my plug-in config now looks like this:

        Code:
        <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
        		<set-property property="contextConfigLocation" 
        	       		     value="/WEB-INF/action-servlet.xml"/> 
        </plug-in>
        now "lazy" should work - even without your "setServlet" approach.

        Comment

        Working...
        X