Hi all,
Using Spring 1.2.8 and Hibernate3 I ran into the LazyInitializationException.
After reading through some threads about it in the forum, I tried the OpenSessionInViewInterceptor which didn't work for me. I still got the same exception.
Then I wanted to give the Filter a shot.
Here's how I defined it in my web.xml:
Code:
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;web-appgt;
lt;servletgt;
lt;servlet-namegt;williswuerstchenlt;/servlet-namegt;
lt;servlet-classgt;
org..web.servlet.DispatcherServletlt;/servlet-classgt;
lt;load-on-startupgt;1lt;/load-on-startupgt;
lt;/servletgt;
lt;servlet-mappinggt;
lt;servlet-namegt;williswuerstchenlt;/servlet-namegt;
lt;ucl-patterngt;*.htmlt;/ucl-patterngt;
lt;/servlet-mappinggt;
lt;welcome-file-listgt;
lt;welcome-filegt;index.jsplt;/welcome-filegt;
lt;/welcome-file-listgt;
lt;listenersgt;
lt;listener-classgt;
org..web.context.ContextLoaderListenerlt;/listener-classgt;
lt;/listenersgt;
lt;context-paramgt;
lt;param-namegt;contextConfigLocationlt;/param-namegt;
lt;param-valuegt;/WEB-INF/applicationContext.xmllt;/param-valuegt;
lt;/context-paramgt;
lt;taglibgt;
lt;taglib-urigt;/springlt;/taglib-urigt;
lt;taglib-locationgt;/WEB-INF/spring.tldlt;/taglib-locationgt;
lt;/taglibgt;
lt;taglibgt;
lt;taglib-urigt;/clt;/taglib-urigt;
lt;taglib-locationgt;/WEB-INF/c.tldlt;/taglib-locationgt;
lt;/taglibgt;
lt;filtergt;
lt;filter-namegt;hibernateFilterlt;/filter-namegt;
lt;filter-classgt;
org..orm.hibernate3.support.OpenSessionInViewFilter
lt;/filter-classgt;
lt;/filtergt;
lt;filter-mappinggt;
lt;filter-namegt;hibernateFilterlt;/filter-namegt;
lt;ucl-patterngt;/*lt;/ucl-patterngt;
lt;/filter-mappinggt;
lt;/web-appgt;
Here's the stack trace I get when calling my webapp:
Code:
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
org..web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:84)
org..orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:221)
org..orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:207)
org..orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:146)
org..web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
I looked for somebody who had similar problems, but it could be solved by specifying the contextConfigLocation, which I already did. But I still get the same exception.
Any help is greatly appreciated.
Cheers,
Daniel
Try changing quot;listenersquot; (plural) to quot;listenerquot; (singular) in your web.xml.
Thanks for your help. Must have overlooked this one...
But I still get the LazyInitializationException when I call order.getOrderItems().
Any clues why? |