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 人气:410
分享到:
blog comments powered by Disqus

相关文章

  • org.apache.struts2.dispatcher.FilterDispatcher 2010-06-30

    1.org.apache.struts2.dispatcher.FilterDispatcher? Is the main Struts2 Filter, responsible for four functions: (1) The Executive Actions (2) Clear ActionContext (3) to maintain static content (4) clear the request life cycle of the interceptors XWork

  • 404 test struts2.0 framework there! Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndEx 2010-04-18

    Error message: java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter [B] Solution: struts.xml <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "ht

  • struts2 source code analysis 2011-07-19

    Struts2 chart Request first by Filter chain, Filter including ActionContextCleanUp, it is mainly clean up the current thread ActionContext and Dispatcher; FilterDispatcher mainly through AcionMapper to decide what you need to call Action. ActionMappe

  • struts2 source code analysis - Request Process 2011-07-19

    Struts2 source code to read - Request Process 2009-06-03 19:49:50 | Category: STRUTS | Tags: | font size medium and small subscription Struts package introduced ( http://www.blogjava.net/lzhidj/archive/2008/07/10/213898.html ) (most of the descriptiv

  • Tomcat 5.5.26 source code analysis - start the process (2) 2010-03-25

    init method Catalina_Home and Catalina_Base Initialize the system class loader Tomcat's class loader system initClassLoaders code Two questions Catalina Object load method Catalina class command-line arguments Loading process start Method await state

  • Liang number regular expression (before and after the search, etc.) And regular packages use apache 2010-06-06

    Generally in the development of a class on the number, some numbers will be reserved for use by members after the upgrade, such as No. Want Want Liang, QQ number, etc., to achieve better use of regular expressions, the background of the page by rules

  • Lucene 3.0.2 Code Analysis 2010-11-16

    Continuously updated Document and Field IndexWriter IndexReader Lucenen achieved in the inverted IndexSearcher Analyzer Sort Filter Lucene's Ranking algorithm and improved 1. Document and Field Document and Field in the index creation process is esse

  • Lucene 3.0.2 code analysis (to) 2010-11-16

    Continuously updated Document And Field IndexWriter IndexReader Lucenen Achieved in the inverted IndexSearcher Analyzer Sort Filter Lucene Ranking in the algorithm and improved 1. Document And Field Document And Field, essential to the process of ind

  • Struts2.2.1 a core source code analysis 2010-11-30

    I. Overview Struts2 is the core of a Filter, Action from the web container can be, then what makes http request and the action associated with, the following source code to our in-depth analysis of how the work under the Struts2. FilterDispatcher API

  • Lucene 3.0.2 code analysis (transfer) 2010-11-16

    Continuously updated Document And Field IndexWriter IndexReader Lucenen Achieved in the inverted IndexSearcher Analyzer Sort Filter Lucene Ranking in the algorithm and improve 1. Document And Field Document And Field in the index creation process is

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

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

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

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