Announcement Announcement Module
Collapse
No announcement yet.
OpenSessionInViewFilter problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • OpenSessionInViewFilter problem

    Hello
    I use struts 2 + spring + hibernate. I configured the OpenSessionInViewFilter but in jsp result i obtain a LazyInitializationException. The filter in configured. So by look at log i can see it HibernateTransactionManager close the hibernate session...why?

    Anyone can help me please?

    Config File web.xml:
    Code:
    	
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="SiCCR" version="2.4"
    	xmlns="http://java.sun.com/xml/ns/j2ee"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    	<display-name>SiCCR</display-name>
    	<filter>
    		<filter-name>struts2</filter-name>
    		<filter-class>
    			org.apache.struts2.dispatcher.FilterDispatcher
    		</filter-class>
    		<init-param>
    			<param-name>actionPackages</param-name>
    			<param-value>it.filosganga.sic.web.actions</param-value>
    		</init-param>
    	</filter>
    
            <filter>
    		<filter-name>hibernateFilter</filter-name>
    	<filter-class>
    			org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    		</filter-class>
    		<init-param>
    			<param-name>singleSession</param-name>
    			<param-value>true</param-value>
    		</init-param>
    		<init-param>
    			<param-name>sessionFactoryBeanName</param-name>
    			<param-value>sessionFactory</param-value>
    		</init-param>
    	</filter>
    
    	<filter-mapping>
    		<filter-name>struts2</filter-name>
    		<url-pattern>/*</url-pattern>
    	</filter-mapping>
    		
    	<filter-mapping>
    		<filter-name>hibernateFilter</filter-name>
    		<url-pattern>*.action</url-pattern>
    	</filter-mapping>
    	
    		<filter-mapping>
    		<filter-name>hibernateFilter</filter-name>
    		<url-pattern>*.jsp</url-pattern>
    	</filter-mapping>
    
    	<welcome-file-list>
    		<welcome-file>index.jsp</welcome-file>
    	</welcome-file-list>
    
    	<listener>
    		<listener-class>
    			org.springframework.web.context.ContextLoaderListener
    		</listener-class>
    	</listener>
    
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>classpath*:applicationContext*.xml</param-value>
    	</context-param>
    </web-app>
    Log:
    Code:
    Hibernate: select this_.grp_id as grp1_3_0_, this_.grp_version as grp2_3_0_, this_.grp_name as grp3_3_0_ from groups this_
    Hibernate: select roles0_.grp_id as grp1_0_, roles0_.rol_name as rol2_0_ from groups_roles roles0_ where roles0_.grp_id in (?, ?, ?, ?, ?, ?)
    2007-07-06 01:14:12,843 HibernateTemplate DEBUG - Not closing pre-bound Hibernate Session after HibernateTemplate
    2007-07-06 01:14:12,843 TransactionInterceptor DEBUG - Completing transaction for [it.filosganga.orm.dao.DAO.findAll]
    2007-07-06 01:14:12,843 TransactionInterceptor DEBUG - Completing transaction for [it.filosganga.sic.business.logic.GroupService.findAll]
    2007-07-06 01:14:12,843 HibernateTransactionManager DEBUG - Triggering beforeCommit synchronization
    2007-07-06 01:14:12,843 HibernateTransactionManager DEBUG - Triggering beforeCompletion synchronization
    2007-07-06 01:14:12,843 HibernateTransactionManager DEBUG - Initiating transaction commit
    2007-07-06 01:14:12,843 HibernateTransactionManager DEBUG - Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@140b8fd]
    2007-07-06 01:14:12,873 HibernateTransactionManager DEBUG - Triggering afterCommit synchronization
    2007-07-06 01:14:12,873 HibernateTransactionManager DEBUG - Triggering afterCompletion synchronization
    2007-07-06 01:14:12,873 TransactionSynchronizationManager DEBUG - Clearing transaction synchronization
    2007-07-06 01:14:12,873 TransactionSynchronizationManager DEBUG - Removed value [org.springframework.orm.hibernate3.SessionHolder@179c7cf] for key [org.hibernate.impl.SessionFactoryImpl@2d0483] from thread [http-8080-2]
    2007-07-06 01:14:12,893 TransactionSynchronizationManager DEBUG - Removed value [org.springframework.jdbc.datasource.ConnectionHolder@5f1c48] for key [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge11u7n16cw22a1eiqry8|d507e9, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge11u7n16cw22a1eiqry8|d507e9, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://localhost:3306/ccr_3, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 100, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 0, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]] from thread [http-8080-2]
    2007-07-06 01:14:12,893 HibernateTransactionManager DEBUG - Closing Hibernate Session [org.hibernate.impl.SessionImpl@140b8fd] after transaction
    2007-07-06 01:14:12,893 SessionFactoryUtils DEBUG - Closing Hibernate Session

  • #2
    I'm stupid

    The filters order is inverse!!! :o

    Comment

    Working...
    X