Hi people,

I am still battling this LazyInitializationException using JPA+Spring+Hibernate.

I have followed suggestions such as
1) move the filter definition for OpenEntityManagerInViewFilter to the top of the web.xml file so to be the first filter to intercept calls
2)Observe log files to see if the OpenEntityManagerInViewFilter is firing. It looks like it is:

Java Code:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.logixplayer.pf.domain.Category.topics, no session or session was closed
	org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
	org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
	org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
	org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
	org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:163)
	com.logixplayer.pf.category.controller.CategoryController.onSubmit(CategoryController.java:38)
	org.springframework.web.servlet.mvc.SimpleFormController.onSubmit(SimpleFormController.java:409)
	org.springframework.web.servlet.mvc.SimpleFormController.onSubmit(SimpleFormController.java:381)
	org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267)
	org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:265)
	org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
	org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:112)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
I am missing something but I do not know what!
I know why I am getting the exception as I stated in my earlier post. The session is being closed when I try to access children (topics) of each category (parent). This is why I was trying to use OpenEntityManagerInViewFilter in the first place.
My only hunch is that the sessions are not unique but distinct. I.e. the session that is being used to get Categories is not being kept open for some reason.

Java Code:
	public ModelAndView onSubmit(Object command) throws ServletException {
		//new ModelAndView(new RedirectView(getSuccessView())); 
		//return new ModelAndView("profile/form","profile1","profile2");
		
		CategoryBean categoryBean = (CategoryBean) command;
		System.out.println("the name from the command bean is: "+categoryBean.getName());
		
		
		//	call category service
		//iCategoryService
		ICategoryService categoryService = (ICategoryService)DataAccessServiceFactory.getBean("iCategoryService");
		List<Category> categories = categoryService.findByName("Autos", null);
		for (Category category : categories) {
			System.out.println("category: "+category.getName());
			System.out.println("****now to get topics if there are any!****");
			Set<Topic> topics = category.getTopics(); [B]<------ Point where I get Lazy Exception!!![/B]
			for (Topic topic : topics) {
				System.out.println("topic: "+topic.getTitle());
				System.out.println("****now to get submissions if there are any!****");
				Set<Submission> submissions = topic.getSubmissions();
				for (Submission submission : submissions) {
					System.out.println("submission topic: " +submission.getTopic());
					System.out.println("submission title: " +submission.getTitle());
				}
			}
		}
		return new ModelAndView("registration/registration","profile1","profile2");
In my web.xml, I declare this:

Java Code:
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>
					<!-- classpath:applicationContext.xml  -->
					<!-- classpath:/data-access-context.xml  -->
					classpath:data-access-context.xml
		</param-value>
	</context-param>
which references my entityManagerFactory like so:

data-access-context.xml:

Java Code:
		<bean id="entityManagerFactory"
			class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
			<property name="persistenceUnitName" value="dataAccessPU" />
		</bean>
		<bean id="transactionManager"
			class="org.springframework.orm.jpa.JpaTransactionManager">
			<property name="entityManagerFactory"
				ref="entityManagerFactory" />
		</bean>
		
		<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
The only thing that jumps out at me is the class definition for OpenEntityManagerInViewFilter:

Java Code:
Servlet 2.3 Filter that binds a JPA EntityManager to the thread for the entire processing of the request. Intended for the "Open EntityManager in View" pattern, i.e. to allow for lazy loading in web views despite the original transactions already being completed.
Servlet 2.3???
I am using Servlet 2.5 and JSP 2.1.
Does OpenEntityManagerInViewFilter not work for servlet 2.5 specs??

I am totally stumped

Anyone can lend some help? Please do...I have been stuck for a very long time
Thanks so much!!