liujianche11 2010-08-17 16:00
浏览 229
已采纳

SSH中hibernate延迟关闭session问题

spring中延迟关闭Session我在web.xml配置了
<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<!-- 加载Struts2控制器 -->

FilterDispatcher
org.apache.struts2.dispatcher.FilterDispatcher

<filter-mapping>
    <filter-name>FilterDispatcher</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<!-- 将Hibernate的Session生命延长,为了解决由于Hibernate延迟加载,Session过早关闭问题 -->
<filter>
    <filter-name>OpenSessionInViewFilter</filter-name>
    <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>OpenSessionInViewFilter</filter-name>
    <url-pattern>*.action</url-pattern>
</filter-mapping>

<!-- 加载Spring容器 -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext-*.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>


index.jsp


然后 tomcat服务器就启动报错报下面的错
严重: Exception starting filter OpenSessionInViewFilter
java.lang.NoSuchFieldError: MANUAL
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.(OpenSessionInViewFilter.java:102)

望各位大哥大姐帮忙

  • 写回答

7条回答 默认 最新

  • oyj7454103 2010-08-17 16:34
    关注

    [color=red]import org.hibernate.*;[/color]
    import org.springframework.web.context.WebApplicationContext;
    import org.springframework.web.context.support.WebApplicationContextUtils;
    import org.springframework.web.filter.OncePerRequestFilter;

    public class OpenSessionInViewFilter extends OncePerRequestFilter
    {

    public OpenSessionInViewFilter()
    {
        sessionFactoryBeanName = "sessionFactory";
        singleSession = true;
        [color=red]flushMode = FlushMode.MANUAL;[/color]    }
    

    我看了下 spring 源码! 找到了这个变量! 是hibernate的!

    所以把你的hibernate 的包换一下绝对OK!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。