2 qq 35900266 qq_35900266 于 2017.09.16 01:39 提问

java.lang.NoSuchMethodError异常

严重: Servlet.service() for servlet [springMVC] in context with path [/gameManage] threw exception [Filter execution threw an exception] with root cause
java.lang.NoSuchMethodError: org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.isAsyncDispatch(Ljavax/servlet/http/HttpServletRequest;)Z
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:208)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:380)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

请问一下这个异常是什么原因导致的呢?

6个回答

qq_39497330
qq_39497330   2017.09.16 09:21

应该是SpringMVC配置文件异常,他说打开视图没有找到方法

qq_34850405
qq_34850405   2017.09.16 09:43

gameManage 看下这个配置

qq_35900266
qq_35900266 几个配置就在下边了,有点乱,谢谢了哇
2 个月之前 回复
qq_35900266
qq_35900266 /gameManage/src/config/spring/applicationContext-shiro.xml
2 个月之前 回复
qq_35900266
qq_35900266   2017.09.16 09:54

/gameManage/src/config/spring/applicationContext-shiro.xml

<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"
default-lazy-init="true">

<description>Shiro安全配置</description>


<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"></bean>

<!-- 数据库保存的密码是使用MD5算法加密的,所以这里需要配置一个密码匹配对象 -->
<bean id="credentialsMatcher" class="org.apache.shiro.authc.credential.Md5CredentialsMatcher"></bean>

<!-- 缓存管理 -->
<bean id="cacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager"></bean>
<!-- 使用Shiro自带的JdbcRealm类 指定密码匹配所需要用到的加密对象 指定存储用户、角色、权限许可的数据源及相关查询语句 -->
<bean id="jdbcRealm" class="org.apache.shiro.realm.jdbc.JdbcRealm">
    <property name="credentialsMatcher" ref="credentialsMatcher"></property>

    <property name="permissionsLookupEnabled" value="true"></property>
     <property name="dataSource" ref="dataSource"></property> 
    <property name="authenticationQuery"
        value="SELECT password FROM T_USER WHERE userName = ? AND del=1"></property>
    <!-- 用户权限 管理员OR普通用户 -->
    <property name="userRolesQuery"
        value="SELECT user_type FROM T_USER WHERE userName = ?"></property>
    <!-- 用户角色 0,0,0,1 -->
    <property name="permissionsQuery"
        value="SELECT user_type FROM T_USER WHERE userName = ?"></property>
</bean>

<!-- Shiro安全管理器 -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
    <property name="realm" ref="jdbcRealm"></property>
    <property name="cacheManager" ref="cacheManager"></property>
</bean>

<!-- Shiro主过滤器本身功能十分强大,其强大之处就在于它支持任何基于URL路径表达式的、自定义的过滤器的执行 Web应用中,Shiro可控制的Web请求必须经过Shiro主过滤器的拦截,Shiro对基于Spring的Web应用提供了完美的支持 -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
    <!-- Shiro的核心安全接口,这个属性是必须的 -->
    <property name="securityManager" ref="securityManager"></property>
    <!-- 要求登录时的链接(登录页面地址),非必须的属性,默认会自动寻找Web工程根目录下的"/login.jsp"页面 -->
    <property name="loginUrl" value="/login"></property>
    <!-- 登录成功后要跳转的连接(本例中此属性用不到,因为登录成功后的处理逻辑在LoginController里硬编码) -->
      <property name="successUrl" value="/index"></property> 
    <!-- 用户访问未对其授权的资源时,所显示的连接 -->
    <property name="unauthorizedUrl" value="/login"></property>
    <property name="filterChainDefinitions">
        <value>
            /login = anon
            /login/toLogin = anon
            /login/** = authc
            /static/**=anon
            /** = authc
            /logout = logout
        </value>
    </property>
</bean>


<!-- 用户授权信息Cache, 采用EhCache -->
<bean id="shiroEhcacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
    <property name="cacheManagerConfigFile" value="classpath*:config/ehcache/ehcache-shiro.xml" />
</bean>

qq_35900266
qq_35900266   2017.09.16 09:56

/gameManage/src/config/spring/spring-common.xml

<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">

 <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
    <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
    <property name="url" value="jdbc:mysql://localhost:3306/gameManage"></property>
    <property name="username" value="root"></property>
    <property name="password" value="zkdjsqladmin"></property>
</bean> 
<!-- <bean id="dataSource2" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
    <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
    <property name="url" value="jdbc:mysql://rds8l3889yql6705lkkepublic.mysql.rds.aliyuncs.com:3306/pmptest"></property>
    <property name="username" value="pmptest"></property>
    <property name="password" value="zhkj_yqgj"></property>
    <property name="url" value="jdbc:mysql://localhost:3306/pmptest"></property>
    <property name="username" value="root"></property>
    <property name="password" value="zkdjsqladmin"></property>

</bean> -->
 <!-- 配置数据源2~~sqlserver -->
  <bean id="dataSource2"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
    <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
    <property name="url" value="jdbc:sqlserver://localhost:1433/DatabaseName=QPAccountsDB" />
    <property name="username" value="sa" />
    <property name="password" value="123456" />
</bean> 



<!-- 配置SessionFactory1-->
 <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.format_sql">true</prop>
        </props>
    </property>
    <property name="annotatedClasses">
        <list>
            <value>com.tgb.entity.TUser</value>
            <value>com.tgb.entity.TBank</value>
            <value>com.tgb.entity.TCommExtract</value>
            <value>com.tgb.entity.TUserResources</value>
            <value>com.tgb.entity.TRecord</value>
            <value>com.tgb.entity.THorseRaceLamp</value>
            <value>com.tgb.entity.TGoods</value>
            <value>com.tgb.entity.TUserGoods</value>

        </list>
    </property>
</bean> 

<!-- 配置SessionFactory2 -->
<!-- <bean id="sessionFactory2" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource2" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.format_sql">true</prop>
        </props>
    </property>
    <property name="annotatedClasses">
        <list>
            <value>com.tgb.entity.TRegister</value>
        </list>
    </property>
</bean> -->


<!-- 配置SessionFactory2~~sqlserver   -->

 <bean id="sessionFactory2"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource2" />

    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
    <prop key="hibernate.hbm2ddl.auto">update</prop>
    <prop key="hibernate.show_sql">false</prop>
    <prop key="hibernate.format_sql">true</prop>
    </props>
    </property> 

    <!--  <property name="annotatedClasses">
    <list>
    <value>com.hengqinhr.entity.TUser</value>

    </list>
    </property> -->
</bean> 


<!-- 配置一个事务管理器1 -->
 <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>

 <bean id="transactionManager2" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory2"/>
</bean>  


<!-- 配置事务,使用代理的方式1 -->









PROPAGATION_REQUIRED,-Exception

PROPAGATION_REQUIRED,-myException

PROPAGATION_REQUIRED

PROPAGATION_REQUIRED





<bean id="transactionProxy2" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">  
    <property name="transactionManager" ref="transactionManager2"></property>  
    <property name="transactionAttributes">  
        <props>  
            <prop key="add*">PROPAGATION_REQUIRED,-Exception</prop>  
            <prop key="modify*">PROPAGATION_REQUIRED,-myException</prop>  
            <prop key="del*">PROPAGATION_REQUIRED</prop>  
            <prop key="*">PROPAGATION_REQUIRED</prop>  
        </props>  
    </property>  
</bean>   

qq_35900266
qq_35900266   2017.09.16 09:57

/gameManage/src/config/spring/spring-mvc.xml

<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">

<!-- 注解扫描包 -->
<context:component-scan base-package="com.tgb" />

<!-- 开启注解 -->
<mvc:annotation-driven />


<!-- <bean id="systemJob" class="com.tgb.service.task.SpringTask"></bean> -->
<!-- 计划任务 -->
<!-- <task:scheduled-tasks scheduler="myscheduler">
    每天00:00 处理
    <task:scheduled ref="systemJob" method="updateVisit"
        cron="0 0 0 * * *" />
    每周星期天凌晨00:00 处理
    <task:scheduled ref="systemJob" method="updateVisitWeek"
        cron="0 0 0 * * 7" />
</task:scheduled-tasks> -->

<task:scheduler id="myscheduler" pool-size="10" />

<!-- 静态资源(js/image)的访问 -->
<mvc:resources location="/static/" mapping="/static/**" />

<!-- 采用SpringMVC自带的JSON转换工具,支持@ResponseBody注解 -->
<bean
    class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="messageConverters">
        <list>
            <bean
                class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
        </list>
    </property>
</bean>

<!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
<bean id="mappingJacksonHttpMessageConverter"
    class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
    <property name="supportedMediaTypes">
        <list>
            <value>text/html;charset=UTF-8</value>
        </list>
    </property>
</bean>

<!-- 定义视图解析器 -->
<bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/view/"></property>
    <property name="suffix" value=".jsp"></property>
</bean>


<!-- SpringMVC上传文件时,需要配置MultipartResolver处理器 -->
<bean id="multipartResolver"
    class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <property name="defaultEncoding" value="utf-8" />
    <property name="maxUploadSize" value="10485760000" />
    <property name="maxInMemorySize" value="40960" />
</bean>

<!-- 将Controller抛出的异常转到特定View, 保持SiteMesh的装饰效果 -->
<bean
    class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
    <property name="exceptionMappings">
        <props>
            <prop key="java.lang.Throwable">/error/500</prop>
        </props>
    </property>
</bean>


<!-- shiro -->
<bean
    class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
    <property name="exceptionMappings">
        <props>
            <prop key="org.apache.shiro.authz.UnauthorizedException">view/account/login.jsp</prop>
        </props>
    </property>
</bean>

<bean
    class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
    depends-on="lifecycleBeanPostProcessor" />
<bean
    class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
    <property name="securityManager" ref="securityManager" />
</bean>

qq_35900266
qq_35900266   2017.09.16 09:57

/gameManage/WebContent/WEB-INF/web.xml

<?xml version="1.0" encoding="UTF-8"?>

json_test

view/account/login.jsp

<!-- 加载所有的配置文件 -->

contextConfigLocation
classpath*:config/spring/spring-*.xml,classpath*:config/spring/applicationContext-shiro.xml

<!-- 配置Spring监听 -->

org.springframework.web.context.ContextLoaderListener

<!-- Shiro Filter -->



shiroFilter

org.springframework.web.filter.DelegatingFilterProxy



targetFilterLifecycle

true







shiroFilter

/*

<!-- 配置SpringMVC -->

springMVC
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
classpath*:config/spring/spring-mvc.xml

1


springMVC
/

<!-- 配置字符集 -->

encodingFilter
org.springframework.web.filter.CharacterEncodingFilter

encoding
UTF-8


forceEncoding
true



encodingFilter
/*

<!-- 配置Session -->

openSession
org.springframework.orm.hibernate4.support.OpenSessionInViewFilter



openSession
/*

<error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/view/error/500.jsp</location>
</error-page>
<error-page>
    <error-code>500</error-code>
    <location>/view/error/500.jsp</location>
</error-page>
<error-page>
    <error-code>404</error-code>
    <location>/view/error/404.jsp</location>
</error-page>

Csdn user default icon
上传中...
上传图片
插入图片