今天在做spring+mybatis+springmvc+shiro的时候,报这个错,刚开始以为是shiro登录验证出错,后来,观看一下错误,发现在别的xml中写错了代码,shiro接连着报错,记录一下
org.apache.shiro.authc.AuthenticationException: Authentication failed for token submission [org.apache.shiro.authc.UsernamePasswordToken - starzou, rememberMe=false]. Possible unexpected error? (Typical or expected login exceptions should extend from AuthenticationException). at org.apache.shiro.authc.AbstractAuthenticator.authenticate(AbstractAuthenticator.java:214) at org.apache.shiro.mgt.AuthenticatingSecurityManager.authenticate(AuthenticatingSecurityManager.java:106) at org.apache.shiro.mgt.DefaultSecurityManager.login(DefaultSecurityManager.java:270) at org.apache.shiro.subject.support.DelegatingSubject.login(DelegatingSubject.java:256) at com.timestech.wsgk.web.controller.UsersController.login(UsersController.java:64) at com.timestech.wsgk.web.controller.UsersController$$FastClassBySpringCGLIB$$5240b5b.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:640) at com.timestech.wsgk.web.controller.UsersController$$EnhancerBySpringCGLIB$$8d1ad011.login(<generated>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:690) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221) 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:383) 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:344) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.timestech.wsgk.web.dao.UsersMapper.authentication at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:178) at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:38) at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:49) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:42) at com.sun.proxy.$Proxy15.authentication(Unknown Source) at com.timestech.wsgk.web.service.impl.UsersServiceImpl.authentication(UsersServiceImpl.java:45) at com.timestech.wsgk.web.service.impl.UsersServiceImpl$$FastClassBySpringCGLIB$$d354a459.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:711) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644) at com.timestech.wsgk.web.service.impl.UsersServiceImpl$$EnhancerBySpringCGLIB$$7292771.authentication(<generated>) at com.timestech.wsgk.web.security.SecurityRealm.doGetAuthenticationInfo(SecurityRealm.java:78) at org.apache.shiro.realm.AuthenticatingRealm.getAuthenticationInfo(AuthenticatingRealm.java:568) at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doSingleRealmAuthentication(ModularRealmAuthenticator.java:180) at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doAuthenticate(ModularRealmAuthenticator.java:267) at org.apache.shiro.authc.AbstractAuthenticator.authenticate(AbstractAuthenticator.java:198) ... 59 more Caused by: org.apache.ibatis.builder.IncompleteElementException: Could not find SQL statement to include with refid 'com.timestech.wsgk.web.dao.OrganizationMapper.Example_Where_Clause' at org.apache.ibatis.builder.xml.XMLIncludeTransformer.findSqlFragment(XMLIncludeTransformer.java:62) at org.apache.ibatis.builder.xml.XMLIncludeTransformer.applyIncludes(XMLIncludeTransformer.java:37) at org.apache.ibatis.builder.xml.XMLIncludeTransformer.applyIncludes(XMLIncludeTransformer.java:50) at org.apache.ibatis.builder.xml.XMLIncludeTransformer.applyIncludes(XMLIncludeTransformer.java:50) at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:83) at org.apache.ibatis.session.Configuration.buildAllStatements(Configuration.java:682) at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:613) at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:608) at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:176) ... 81 more Caused by: java.lang.IllegalArgumentException: XML fragments parsed from previous mappers does not contain value for com.timestech.wsgk.web.dao.OrganizationMapper.Example_Where_Clause at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:775) at org.apache.ibatis.builder.xml.XMLIncludeTransformer.findSqlFragment(XMLIncludeTransformer.java:58) ... 89 more
写错代码的位置
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.timestech.wsgk.web.dao.OrganizationMapper" > <resultMap id="BaseResultMap" type="com.timestech.wsgk.web.model.Organization" > <id column="ID" property="id" jdbcType="VARCHAR" /> <result column="NAME" property="name" jdbcType="VARCHAR" /> <result column="ISROOT" property="isroot" jdbcType="DECIMAL" /> <result column="PARENTNODE" property="parentnode" jdbcType="VARCHAR" /> <result column="ORGANIZATION_ID" property="organizationId" jdbcType="VARCHAR" /> <result column="DESCRIPTION" property="description" jdbcType="VARCHAR" /> <result column="STATUS" property="status" jdbcType="DECIMAL" /> </resultMap> <sql id="Base_Column_List" > ID, NAME, ISROOT, PARENTNODE, ORGANIZATION_ID, DESCRIPTION, STATUS </sql> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="Long" > select <include refid="Base_Column_List" /> from BJLT.ORGANIZATION where ID = #{id,jdbcType=VARCHAR} </select> <delete id="deleteByPrimaryKey" parameterType="Long" > delete from BJLT.ORGANIZATION where ID = #{id,jdbcType=VARCHAR} </delete> <insert id="insert" parameterType="com.timestech.wsgk.web.model.Organization" > insert into BJLT.ORGANIZATION (ID, NAME, ISROOT, PARENTNODE, ORGANIZATION_ID, DESCRIPTION, STATUS) values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{isroot,jdbcType=DECIMAL}, #{parentnode,jdbcType=VARCHAR}, #{organizationId,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{status,jdbcType=DECIMAL}) </insert> <insert id="insertSelective" parameterType="com.timestech.wsgk.web.model.Organization" > <selectKey resultType="java.lang.String" keyProperty="id" order="BEFORE"> select sys_guid() from dual </selectKey> insert into BJLT.ORGANIZATION <trim prefix="(" suffix=")" suffixOverrides="," > <if test="id != null" > ID, </if> <if test="name != null" > NAME, </if> <if test="isroot != null" > ISROOT, </if> <if test="parentnode != null" > PARENTNODE, </if> <if test="organizationId != null" > ORGANIZATION_ID, </if> <if test="description != null" > DESCRIPTION, </if> <if test="status != null" > STATUS, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides="," > <if test="id != null" > #{id,jdbcType=VARCHAR}, </if> <if test="name != null" > #{name,jdbcType=VARCHAR}, </if> <if test="isroot != null" > #{isroot,jdbcType=DECIMAL}, </if> <if test="parentnode != null" > #{parentnode,jdbcType=VARCHAR}, </if> <if test="organizationId != null" > #{organizationId,jdbcType=VARCHAR}, </if> <if test="description != null" > #{description,jdbcType=VARCHAR}, </if> <if test="status != null" > #{status,jdbcType=DECIMAL}, </if> </trim> </insert> <update id="updateByPrimaryKeySelective" parameterType="com.timestech.wsgk.web.model.Organization" > update BJLT.ORGANIZATION <set > <if test="name != null" > NAME = #{name,jdbcType=VARCHAR}, </if> <if test="isroot != null" > ISROOT = #{isroot,jdbcType=DECIMAL}, </if> <if test="parentnode != null" > PARENTNODE = #{parentnode,jdbcType=VARCHAR}, </if> <if test="organizationId != null" > ORGANIZATION_ID = #{organizationId,jdbcType=VARCHAR}, </if> <if test="description != null" > DESCRIPTION = #{description,jdbcType=VARCHAR}, </if> <if test="status != null" > STATUS = #{status,jdbcType=DECIMAL}, </if> </set> where ID = #{id,jdbcType=VARCHAR} </update> <update id="updateByPrimaryKey" parameterType="com.timestech.wsgk.web.model.Organization" > update BJLT.ORGANIZATION set NAME = #{name,jdbcType=VARCHAR}, ISROOT = #{isroot,jdbcType=DECIMAL}, PARENTNODE = #{parentnode,jdbcType=VARCHAR}, ORGANIZATION_ID = #{organizationId,jdbcType=VARCHAR}, DESCRIPTION = #{description,jdbcType=VARCHAR}, STATUS = #{status,jdbcType=DECIMAL} where ID = #{id,jdbcType=VARCHAR} </update> <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.timestech.wsgk.web.model.UserExample"> -----------------这个是多余的 select <if test="distinct"> distinct </if> <include refid="Base_Column_List" /> from BJLT.USERS <if test="_parameter != null"> <include refid="Example_Where_Clause" /> ------------------------错误根源 </if> <if test="orderByClause != null"> order by ${orderByClause} </if> </select> </mapper>
对应的mapper
package com.timestech.wsgk.web.dao; import java.util.List; import com.timestech.wsgk.core.generic.GenericDao; import com.timestech.wsgk.web.model.Organization; public interface OrganizationMapper extends GenericDao<Organization, String>{ /** * 描述:根据ID删除记录 */ int deleteByPrimaryKey(String id); /** * 描述:新增organization记录 * @param organization * @return */ int insert(Organization organization); /** * 描述:新增organization记录,有参数新增,没参数空着 */ int insertSelective(Organization organization); /** * 描述:根据ID查询实体 */ Organization selectByPrimaryKey(String id); /** * 描述:修改organization记录,有参数修改,没参数空着 */ int updateByPrimaryKeySelective(Organization organization); /** * 描述:修改organization记录,参数全部修改 * @param organization * @return */ int updateByPrimaryKey(Organization organization); /** * 描述:根据条件查询用户集合 * @param example * @return */ List<Organization> selectList(Organization organization); }