关于SSH2框架中Filter的问题 1C

我是初学者,下载了一个SSH学习框架SSH2框架搭建实例,但是遇到了这样的问题,已经几天了,都没搞定,还望有大神能帮帮忙,指点迷津。
详细情况是这样的,框架本身是Struts2.3.4+Spring3.2+Hibernate4.2,使用的Oracle数据库,我机子上装的MySQL,所以就把数据库换了。然后用的Tomcat7.0发布的。
遇到了这样的问题:

  1. 严重: Servlet.service() for servlet [jsp] in context with path [/ssh2_test] threw exception [Filter execution threw an exception] with root cause
    java.lang.NoSuchMethodError: org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.isAsyncDispatch(Ljavax/servlet/http/HttpServletRequest;)Z

  2. at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:139)

  3. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    ........

Web.xml配置代码如下:

 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <display-name>ssh2_test</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <filter>
        <filter-name>CharsetEncodingFilter</filter-name>
        <filter-class>com.jialin.filter.CharsetEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>GB18030</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>CharsetEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!-- 配置spring资源 -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:config/applicationContext-*.xml</param-value>
    </context-param>

    <!-- 配置CharacterEncoding,设置字符集 -->
    <!-- <filter> <filter-name>characterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> 
        <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> 
        </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> 
        </init-param> </filter> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> 
        <url-pattern>/*</url-pattern> </filter-mapping> -->




    <!-- 将HibernateSession开关控制配置在Filter,保证一个请求一个session,并对lazy提供支持 -->
     <filter>
        <filter-name>OpenSessionInView</filter-name>
        <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
        <init-param>
            <param-name>singleSession</param-name>
            <param-value>true</param-value>
        </init-param>

    </filter>

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

    <!-- 配置Struts2 -->
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        <init-param>
            <param-name>config</param-name>
            <param-value>struts-default.xml,struts-plugin.xml,/config/struts.xml</param-value>
        </init-param>
    </filter>

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


    <!-- 配置spring -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

</web-app>

如果把OpenSessionInView过滤器注释掉,倒不会有这个问题,但是有些效果就没有了。
不知道这样的描述够不够,应该是在OpenSessionInView过滤器这里出了什么问题,还望有大神能告知解决办法!谢谢!

3个回答

检查jar包
你没找到这个方法,应该是jar漏了
spring-orm.jar

java.lang.NoSuchMethodError: org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.isAsyncDispatch(Ljavax/servlet/http/HttpServletRequest;)Z

依赖包不存在!检查下lib中的spring jar包是否全了。建议使用maven搭建工程,引入SPRING时会将其以来自动引入!也便于管理里项目中的依赖包

请问您解决了吗?我遇到了一样的问题

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问