shiro错误总结

今天在做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);
}
时间: 2024-08-03 01:20:11

shiro错误总结的相关文章

shiro的权限控制应用,集成spring项目,密码错误次数过多短时间锁定

以前对shiro都是一知半解,最近系统学了一遍shiro并集成到了在做的项目中. 下面就详细向大家描述一下shiro的用法. 首先是对spring的配置文件,如下: 1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:xsi="http://www.w3

Ehcache缓存框架与 Shiro 框架 出现出现验证错误 &amp;&amp; Tomcat 缓存清除的问题

当一个项目使用久了以后就会出现各种问题,下面是我遇到的一个权限验证错误的问题 我的项目是   Ehcache 结合 Shiro  一起使用的,项目用用久了出现   Token验证错误,Cookie之类的...浏览器访问出现500 各种奇葩 我的做法是: 清除Google Chrome的 Cookie,和自动填表的功能 发现部署项目的时候,是可以部署的   而且可以打开首页 当输入账号密码,到后台验证的时候,出现错误 并且提示是Ehcache 与  Cookie之间的Token之类的错误 我想大概

Shiro中的Rememberme后出现浏览器500错误

问题详述:在Shiro中添加Remember me功能后,只要勾选Remember me选项为true的时候,浏览器就会跳转到一个不可达页面,并且在Chrome中显示HTTP 500错误. 问题追踪: 1. 设置Shiro的日志权限级别为DEBUG log4j设置 # Default Shiro logging log4j.logger.org.apache.shiro=DEBUG 2.点击登录按钮,查看日志输入: DEBUG - Authentication successful for to

shiro框架---bug调试(账号错误)

1 package cn.lqp.shrio.test; 2 3 import org.apache.shiro.SecurityUtils; 4 import org.apache.shiro.authc.AuthenticationException; 5 import org.apache.shiro.authc.UsernamePasswordToken; 6 import org.apache.shiro.config.IniSecurityManagerFactory; 7 impo

Shiro框架--bug调试之(密码错误)

shiro.ini1 ##填写用户信息 2 [users] 3 admin=123456,role_admin,role_user 4 5 [roles] 6 role_admin=user:to_edit,user:to_add,user:add 7 role_user = modular:add 测试代码: 1 package cn.lqp.shrio.test; 2 3 import org.apache.shiro.SecurityUtils; 4 import org.apache.s

sringboot2+shiro json接口形式未登录时报https中有http请求错误

最近开发一个小项目采用springboot2+shiro前后端分离的方式进行.由于访问使用https证书形式.结果在上线时遇到登录信息过期后shiro设置的跳转接口时重定向为http.从而https访问http报错.网上找了很多都没有一个很好的解决办法. ? ? 一开始想通过redirectHttp10Compatible:解决https环境下使用redirect重定向地址变为http的协议,无法访问服务的问题??? ? ? ? ? ? 设置为false,即关闭了对http1.0协议的兼容支持

Shiro登录错误500(rememberMe=true情况下)

描述:debugger信息在"Added HttpServletResponse Cookie [rememberMe=jCT60vZQbUSFVlE......"就不往下走了,断点调试,发现已经登录成功,跳转到登录url的时候跳转不过去,后台没有报错信息,只是/login请求的http状态码为500:手动进入登录成功后的页面,发现已经登录成功!session信息已经存在,只是没有rememberMe的cookie信息...... 找了好几天,发现去掉下面标注段代码就没有问题,多次验证

shiro遇到404,500,403等错误就需要重新登录的解决办法

最简单的办法: 在404页面 设置<%@ page %> 中设置 session="false" 属性,如:<%@ page session="false" %> 参考:http://jinnianshilongnian.iteye.com/blog/1999182,感谢原作者辛苦付出~ 原文地址:http://blog.51cto.com/1197822/2157680

Shiro学习(6)Realm整合

6.1 Realm [2.5 Realm]及[3.5 Authorizer]部分都已经详细介绍过Realm了,接下来再来看一下一般真实环境下的Realm如何实现. 1.定义实体及关系 即用户-角色之间是多对多关系,角色-权限之间是多对多关系:且用户和权限之间通过角色建立关系:在系统中验证时通过权限验证,角色只是权限集合,即所谓的显示角色:其实权限应该对应到资源(如菜单.URL.页面按钮.Java方法等)中,即应该将权限字符串存储到资源实体中,但是目前为了简单化,直接提取一个权限表,[综合示例]部