org.apache.shiro.web.subject.support.WebDelegatingSubject cannot be cast to com.cy.pj.sys.entity

java.lang.ClassCastException: org.apache.shiro.web.subject.support.WebDelegatingSubject cannot be cast to com.cy.pj.sys.entity.SysUser
	at com.cy.pj.common.util.ShiroUtil.getLoginUser(ShiroUtil.java:16)
	at com.cy.pj.common.util.ShiroUtil.getUsername(ShiroUtil.java:24)
	at com.cy.pj.common.aspect.SysLogAspect.saveLog(SysLogAspect.java:80)
	at com.cy.pj.common.aspect.SysLogAspect.around(SysLogAspect.java:49)
	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.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
	at com.cy.pj.sys.service.impl.SysUserServiceImpl$$EnhancerBySpringCGLIB$$14892791.findPageObjects(<generated>)
	at 

报错代码: return (SysUser)SecurityUtils.getSubject();
SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, user.getPassword(), credentialsSalt, getName());
user对象是身份信息

所以将代码改为: return (SysUser)SecurityUtils.getSubject().getPrincipal();

你可能感兴趣的:(java,java)