hibernate lazy loading failed

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!

分类:Java 时间:2010-02-03 人气:408
分享到:
blog comments powered by Disqus

相关文章

  • 解析web.xml中在Servlet中获取context-param和init-param内的参数 2013-11-20

    本篇文章是对web.xml中在Servlet中获取context-param和init-param内的参数进行了详细的分析介绍,需要的朋友参考下 web.xml里面可以定义两种参数:1.application范围内的参数,存放在servletcontext中,在web.xml中配置如下: <context-param> <param-name>context/param</param-name> <param-value>avalible duri

  • Struts2.0 configuration file (web.xml) 2010-04-19

    web.xml is the web application loads the important information about servlet configuration file, play initialization servlet, filter, etc. The role of web programs. In general, all of the MVC framework for Web applications need to load a core control ...

  • sruts2.0 web.xml configuration file 2011-05-04

    Any MVC framework and Web application integration needs, which had to resort to web.xml file, only the configuration in the web.xml file in the Servlet will be applied load. Usually, all the MVC framework for Web application needs to load a core controlle

  • struts2 configuration in web.xml (rpm) 2011-08-14

    Struts 2 is an overview of the basic configuration in front of the basic content of Struts 2 framework, but these basic elements must be built on the Struts 2 configuration file based on these configuration files configuration information is the core of t

  • Tomcat Performance Tuning (change) 2010-04-07

    1. Introduction Performance testing and analysis is an intermediary in the process of software development, architecture and a wide range of adjustment is not easy to understand and compare the areas, but also a more complex activity. Like a chess game is

  • Struts2 annotation configuration Action 2010-10-28

    In view of recent Struts2 showcase, The intention is to find a simple look, chose person, Or that there is no luck in the lottery, the first example I do not understand the ,person The index.jsp in the so called action The <html> <head>

  • Shindig study notes-REST method request process 2011-04-14

    Reference Note: the original from http://blog.csdn.net/hissippi/archive/2010/06/06/5651729.aspx , for the convenience of my reading, the text format is slightly adjusted. In the Shindig project, a typical request for rest of the way this usually is (

  • 如何建立一个 XML 的开发环境 2014-11-04

    学习 XML 的最佳途经是从简单的开发入手,大胆实践,循序渐进。XML 的妙处只有在开发过程中才能深入体会,离开了开发是学不好 XML 的。因此学习 XML 首先应该建立一个 XML 的开发环境。我给大家介绍一下怎样建立一个基于 Java 的 XML 开发环境。因为我现在没办法用到 Linux,所以所有的例子都是在 Windows 上做的。但是这里介绍的所有的软件在 Linux 和 Windows 上都是可以用的,用法也大同小异。而且除了 Sun 的 JRE 以外都是 open source 软

  • struts1 configuration initialization parameter init-param 2011-08-12

    1, set the initialization value <init-param> element in <servlet> element below, is used to configure the servlet initialization parameters to specify the parameters by <param-name> name, <param-value> to specify parameter val

  • Access to context-param in web.xml and init-param parameter 2010-03-19

    web.xml which can be defined two kinds of parameters: (1) application within the parameters stored in the servletcontext, in the web.xml to configure the following: xml code <context-param> <param-name> context / param </ param-name> ...

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.109 (s). 12 q(s)