-->
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 could not initialize proxy no Session LazyInitializati
PostPosted: Tue Oct 18, 2011 10:19 am 
Newbie

Joined: Fri Oct 14, 2011 6:55 am
Posts: 4
Knowledge on hibernate. Well I have looked at some files in the project.

I am trying to run a jsp page to load and keep getting an error on the page load. The Hibernate Exception that is shown in my logs statements
LazyInitiailizationException.java.
ERROR - could not initialize proxy - no Session org.hibernate.LazyInitializationException: could not initialize proxy - no Session

The web application is using Struts and Hibernate 3 dont know exact version.
In the logs I can see that the Struts Action class shows all the outputs of the log statements that I have put into it all the way up to the return forward line.

So somewhere after the Struts action is hit and it returns it forwards to get the jsp display the web app drops the Session.
The JSP tries to load and reference the session but it is no longer there at which point I get the above exception.

What would you recommend I look into in order to ensure that my Session does not magically disappear on my?

I need to get this fixed today and yeah I can see it as being a joke but I try to do what I'm told.

Thanks for any input.


Top
 Profile  
 
 Post subject: Re: ERROR could not initialize proxy no Session LazyInitializati
PostPosted: Fri Oct 21, 2011 6:03 am 
Newbie

Joined: Fri Nov 12, 2010 4:03 pm
Posts: 5
I have no idea if it could really helps you but in my spring project, I use an interceptor to close the session before view is displayed by freemarker.
So, if I don't manage correctly the fetching, the view will try to access on a fied proxified by Hibernate and display the same error as you.

Can you track the field giving the exception and retriever the hibernate query to force the fetching?
Or disable interceptors?

Are you upgrading Hibernate recently?
Because fetch type default switch from Eager to Lazy.... so...

Hope it helps

Zeil

Code:
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
   <property name="order" value="3" />
   <property name="interceptors">
      <list>
         <ref bean="closeSessionBeforeViewInterceptor" />
      </list>
   </property>
</bean>

<bean id="closeSessionBeforeViewInterceptor" class="myPackage.CloseSessionBeforeViewInterceptor">
    <property name="singleSession" value="true" />
   <property name="sessionFactory" ref="sessionFactory" />
</bean>


Code:
public class CloseSessionBeforeViewInterceptor extends HibernateAccessor implements WebRequestInterceptor {
   //Use org.springframework.orm.hibernate3.SessionFactoryUtils
   ...
}


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.