19-Jul-2018 16:29:08.795 严重 [http-apr-9988-exec-9] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [appServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.ClassCastException: java.lang.String cannot be cast to com.xxx.xxx.model.User] with root cause
 java.lang.ClassCastException: java.lang.String cannot be cast to com.xxx.xxx.model.User
    at com.xxx.xxx.service.ShiroUserService.getLoginUser(ShiroUserService.java:66)
    at com.xxx.xxx.service.ShiroUserService$$FastClassBySpringCGLIB$$f76d8c53.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
    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:266)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
    at com.xxx.xxx.service.ShiroUserService$$EnhancerBySpringCGLIB$$2ac8e047.getLoginUser(<generated>)
    at com.xxx.xxx.controller.IndexController.login(IndexController.java:90)
    at com.xxx.xxx.controller.IndexController$$FastClassBySpringCGLIB$$8a20cfbd.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:649)
    at com.xxx.xxx.controller.IndexController$$EnhancerBySpringCGLIB$$1f3f408c.login(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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:781)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:721)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    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.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2521)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2510)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

初步分析,是两个项目的shiro混淆了

ShiroUserService的方法 getLoginUser

原本的:

​public User getLoginUser() {     org.apache.shiro.subject.Subject my = SecurityUtils.getSubject();      if(my.getPrincipal() == null){my.logout();throw new UnauthenticatedException();}return (User)my.getPrincipal();}​

改为:

 public User getLoginUser() {     org.apache.shiro.subject.Subject my = SecurityUtils.getSubject();      if(my.getPrincipal() == null || !(my.getPrincipal() instanceof User)){my.logout();throw new UnauthenticatedException();}return (User)my.getPrincipal();}

cannot be cast to com.xxx.xxx.model.User] with root cause相关推荐

  1. java.util.LinkedHashMap cannot be cast to xxx.xxx.xxx

    /*** 例: List<JavaBean> pojo= (List<JavaBean>) map.get("tableData");* 遇到错误如下:ja ...

  2. Fegin RPC调用远程接口返回值解析问题:java.util.LinkedHashMap cannot be cast to com.xxx.xxx

    现象: BaseResponse 对象中有个Property名为result,为Object 类型,接口为这个result赋值是一个Map<String, NodeDetail> 对象,结 ...

  3. 解决 springboot + JPA + MySQL 表名全大写 出现 “表不存在” 问题(Table ‘XXX.xxx‘ doesn‘t exist)

    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. 项目中使用 JPA 和 mysql .表名是全大写的. 出现 如下报错: java.sql.SQLS ...

  4. Vue-Proxy error: Could not proxy request xxx/xxx from localhost:9528 to http://ip:port

    问题 vue项目启动后登录报如下错误: App running at:- Local: http://localhost:9528/ - Network: http://192.168.100.26: ...

  5. springboot使用junit单元测试是发生报错 Field taskUtils in com.xxx.xxx.xxxx.xxx required a bean of type 'xxx.xxx.

    使用junit单元测试mybatis时发生如下错误 Error starting ApplicationContext. To display the conditions report re-run ...

  6. Error:(8,16) java: 找不到符号和Error:(9, 15) java: 找不到符号符号:类 xxx位置:程序包 xxx.xxx

    昨天晚上遇到的一个bug,写了一个main方法,发现执行的时候老师报:Error:(15,8) java: 找不到符号和Error:(9, 15) java: 找不到符号符号:类 xxx位置:程序包 ...

  7. 关于使用MyBatis逆向工程生成器把其他数据库的同名表生成下来的问题(Table Configuration xxx matched more than one table (xxx,xxx))

    在使用逆向工程生成类的时候,我遇到了把同名的其它数据库的类给生成下来了的问题.并且Idea也报Warning: Table Configuration xxx matched more than on ...

  8. static String valueOf(XXX xxx)

    1 package day01; 2 /** 3 * static String valueOf(XXX xxx) 4 * 字符串提供了一组静态的重载的valueOf方法,作用 5 * 是将其他类型转 ...

  9. getResources().getIdentifier(textView01, id, cn.xxx.xxx);

    使用getIdentifier()获取资源Id Java代码   int i=  getResources().getIdentifier("icon", "drawab ...

最新文章

  1. 2022-2028年中国汽车修理行业市场前瞻与投资规划分析报告
  2. 白话Elasticsearch70-ES生产集群部署之production mode下启动时的bootstrap check
  3. 第五天2017/04/06(下午1:C、C++混合编程 与 #ifdef __cplusplus extern C{ })
  4. Hadoop For Windows
  5. Acwing 1072. 树的最长路径
  6. linux tar 大小不同,linux – 如何在使用tar时设置bzip2块大小?
  7. SLAM方向公众号、知乎、博客学习参考
  8. 华为云空间联系人是不是机主_华为Mate 30系列国内发布 超强隐私安全保护放大招...
  9. HDU2026 首字母变大写【入门】
  10. 袁玉玮:简介人工智能在基金界的应用现状(四)
  11. Java硬核福利,实战虚拟机+Springboot+缓存,java电子书教材下载
  12. 动态数据源,帆软报表同一个sql语句,根据不同的角色使用不同的连接
  13. kindle DXG 安装多看
  14. JAVA中如何计算文具店总费用,文具店的连锁属于。
  15. 国际商务礼仪与标准接待风范
  16. HALCON学习论坛
  17. 【基础版】大学计算机-计算思维导论
  18. 【MATLAB】求不定积分
  19. Hui-iconfont字符图标不显示或显示异常。
  20. HGE编写游戏的心得体会

热门文章

  1. nvidia Quadro P620在linux下安装驱动
  2. Android应用权限大全(Manifest.permission)
  3. java邮件中添加excel_基于javaMail的邮件发送--excel作为附件
  4. 《让子弹飞》系列——不输的汤师爷
  5. 什么是驻点和拐点_拐点和驻点的区别
  6. 关于抢红包的_面试官让我5分钟内写一个抢红包程序,我和他说了半小时原理!...
  7. 11个免费的Web安全测试工具
  8. 网易2017春招[编程题]赶去公司@Java
  9. Web应用服务器tomcat
  10. 淘宝API item_search_jupage - 天天特价