-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: ERROR LazyInitializationException - could not initialize pro
PostPosted: Tue Jun 07, 2011 8:28 pm 
Newbie

Joined: Tue Mar 15, 2011 8:43 pm
Posts: 2
So I'm having a Spring and Hibernate configuration problem. I keep coming back to this error. Basically as I understand things, I want spring to open a hibernate session and hold this session open for the entire http request and the transaction managed by annotations. This is standard pattern no?

I'm using struts action classes that make calls out to service beans that in turn talk to hibernate.

Well the behaviour I'm seeing is my action makes requests to services annotated with '@Transactional'. In this particular case, my action class method (marked with @Transactional) makes a few calls out to some service classes this part works fine. But later in the method I reference a property of the database bean and I get a lazy load / no session exception.

Should not the session be held open for the length of the request. Here are my config settings thus far:


Code:
<bean id="hibernateDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
   <property name="driverClassName" value="..."/>
   <property name="url" value="..."/>
   <property name="username" value="..."/>
   <property name="password" value="..."/>
</bean>

<bean id="hibernateTxManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
   <property name="dataSource" ref="hibernateDataSource"/>
</bean>

<tx:annotation-driven transaction-manager="hibernateTxManager" proxy-target-class="true"/>

<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
   <property name="dataSource" ref="hibernateDataSource"/>
   <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" /-->
   <property name="mappingLocations">
      <list>
         ....
      </list>
   </property>
   <property name="hibernateProperties">
      <props>
         <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
         <prop key="c3p0.max_size">50</prop>
         <prop key="c3p0.min_size">10</prop>
      </props>
   </property>
</bean>


Is there anything obvious I am missing?

Thanks


Top
 Profile  
 
 Post subject: Re: ERROR LazyInitializationException - could not initialize pro
PostPosted: Tue Jun 07, 2011 10:35 pm 
Newbie

Joined: Wed Jun 24, 2009 9:10 pm
Posts: 10
Please include code/psuedo code for the scenario in question.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.