Announcement Announcement Module
Collapse
No announcement yet.
Already value SessionHolder for key SessionFactoryImpl bound to thread Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Already value SessionHolder for key SessionFactoryImpl bound to thread

    Hi people,
    After configuring the PersistenceContext as explained here using my sessionFactory I get the following error when I start the flow, it seems that it's passing an empty SessionHolder?:

    Code:
    org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'null' of flow 'matriculas/registrar'
    	at org.springframework.webflow.engine.impl.FlowExecutionImpl.wrap(FlowExecutionImpl.java:571)
    	at org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:226)
    	at org.springframework.webflow.executor.FlowExecutorImpl.launchExecution(FlowExecutorImpl.java:140)
    	at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:193)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    ...
    Caused by: java.lang.IllegalStateException: Already value [org.springframework.orm.hibernate3.SessionHolder@3df3bec] for key [org.hibernate.impl.SessionFactoryImpl@34d704f0] bound to thread [http-8080-1]
    	at org.springframework.transaction.support.TransactionSynchronizationManager.bindResource(TransactionSynchronizationManager.java:163)
    	at org.springframework.webflow.persistence.HibernateFlowExecutionListener.bind(HibernateFlowExecutionListener.java:201)
    	at org.springframework.webflow.persistence.HibernateFlowExecutionListener.sessionStarting(HibernateFlowExecutionListener.java:120)
    	at org.springframework.webflow.engine.impl.FlowExecutionListeners.fireSessionStarting(FlowExecutionListeners.java:117)
    	at org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:365)
    	at org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:222)
    	... 55 more
    Here's the Listener Configuration:

    Code:
    <webflow:flow-executor id="flowExecutor">
    		<webflow:flow-execution-listeners>
    			<webflow:listener ref="hibernateFlowExecutionListener" />
    		</webflow:flow-execution-listeners>
    	</webflow:flow-executor>
    	
    	<bean id="hibernateFlowExecutionListener" class="org.springframework.webflow.persistence.HibernateFlowExecutionListener">
    		<constructor-arg ref="sessionFactory" />
    		<constructor-arg ref="transactionManager" />
    	</bean>
    And this is my datasource config:

    Code:
    <bean id="sessionFactory"
    		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource" ref="dataSource"></property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.connection.useUnicode">true</prop>
    				<prop key="hibernate.connection.characterEncoding">utf8</prop>
    				<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
    				<prop key="hibernate.show_sql">false</prop>
    				<prop key="hibernate.connection.autocommit">true</prop>
    				<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
    				<prop key="hibernate.current_session_context_class">thread</prop>
    				<prop key="hibernate.hbm2ddl.auto">none</prop>
    			</props>
    		</property>
    		<property name="mappingDirectoryLocations">
    			<list>
    				<value>classpath:com/si/modelos</value>
    			</list>
    		</property>
    	</bean>
    
    	<tx:advice id="txAdvice">
    		<tx:attributes>
    			<tx:method name="obtener*" read-only="true" />
    			<tx:method name="buscar*" read-only="true" />
    			
    			<tx:method name="*" />
    		</tx:attributes>
    	</tx:advice>
    
    	<aop:config>
    		<aop:pointcut id="serviceMethods" expression="execution(* com.servicios..*Service.*(..))" />
    		<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethods" />
    	</aop:config>
    	
    	<bean name="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
    		<property name="sessionFactory" ref="sessionFactory" />
    	</bean>
    	
    	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    	    <property name="sessionFactory" ref="sessionFactory" />
        </bean>
    And this is the Interceptor configuration for the OpenSessionInView:

    Code:
    <!-- OpenSessionInView -->
    	<mvc:interceptors>
    		<mvc:interceptor>
    			<mvc:mapping path="/**" />
    			<bean class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor" name="openSessionInViewInterceptor">
    				<property name="sessionFactory" ref="sessionFactory" />
    			</bean>
    		</mvc:interceptor>
    	</mvc:interceptors>
    I've also added <persistence-context /> to my flow, and marked with commit="true" to my end state, any idea?
Working...
X