• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Spring-Hibernate: LazyInitializationException

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I'm using Spring and Hibernate in my Web application. When I try to access a hibernate object from my struts action class or my JSP page, I get an exception stating:

Uncaught exception thrown in one of the service methods of the servlet: action. Exception thrown : javax.servlet.ServletException: could not initialize proxy - the owning Session was closed

Does anyone know what I'm doing wrong and how to solve the problem.

Here's my code:


/////WEB.XML//////////////

<!-- =================== Define Spring Bean Definition Files to be loaded ================== -->

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:com/PBCoreApp/architecture/applicationContext.xml</param-value>
</context-param>
<!--
<context-param>
<param-name>parentContextKey</param-name>
<param-value>pb.model</param-value>
</context-param>
-->
<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>
</filter>

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



<!-- =================== Spring Context Loader Servlet ================== -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>


////JAVA CODE//////

BusinessServiceCbo businessServiceCbo = new
BusinessCbo businessCbo = new BusinessCbo();
businessCbo = businessDao.findById(businessId);

List serviceList = new ArrayList( businessCbo.getBusinessServices());
businessDetailsDto.setServiceList(serviceList);

//////ACTION CLASSS///

System.out.println("Service List: " + businessDetailDto.getServiceList()); //error occurs here!!!


///APPLiCATION Context.xml /////

<bean id="businessBSTarget" class="com.PBCoreApp.business.impl.BusinessBSImpl">
<property name="businessDao"><ref local="businessDao" /></property>
</bean>
<bean id="businessBS" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>com.PBCoreApp.business.BusinessBS</value>
</property>
<property name="target">
<ref local="businessBSTarget" />
</property>
<property name="interceptorNames">
<list>
<value>hibernateInterceptor</value>
</list>
</property>
</bean>


/////STRUTS-CONFIG//////

<!-- ============================= Spring Plugin ================================== -->

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property
property="contextConfigLocation"
value="/WEB-INF/presentationContext.xml classpath*:com/PBCoreApp/architecture/applicationContext.xml" />
</plug-in>


Pls...HeLP!!!
 
You get good luck from rubbing the belly of a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic