Concerned about the javaeye has been more than a year, but had no opportunity to write a log. Today, they wanted big cow jokes are not afraid of you wrote a log. Want to beginners strtus, hibernate, spring who have some help.
The lazy loading, I no longer introduced. I believe that if it used the hibernate will have a certain understanding of. The javaeye also saw a lot of similar problems. Here I need not repeat.
If there is a similar error, first check whether the web.xml to configure the following code:
<filter> <filter-name>opensession</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>opensession</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
Many people in the configuration of the above code, but problem is still there. This will be done the following analysis:
Each request, whether it has passed through a OpenSessionInViewFilter this filter. If they do not it, then your configuration is actually invalid. Therefore, I recommend this configuration to the web.xml to configure the first filter to avoid interference! The more I have been to a lot of people ask me, the problem ultimately lies in the place. In particular the inclusion of strtus later. Easily lead to such problems, such as the following configuration:
<!-- Struts filter --> <filter> <filter-name>struts2Filter</filter-name> <filterclass>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
StrutsPrepareAndExecuteFilter configuration must OpenSessionInViewFilter after.
The reason is simple: StrutsPrepareAndExecuteFilter have all been blocked, OpenSessionInViewFilter will fail!