RedisSessionUtil报错,求助

使用框架为ssm,用户登录时,使用shiro校验。我的工作环境在mac上,但同样一套代码在windows下运行正常???
Subjectsubject=SecurityUtils.getSubject();
UsernamePasswordTokenusernamePasswordToken=newUsernamePasswordToken(member.getUsername(),Md5Util.saltPassword(member.getUsername(),password));
usernamePasswordToken.setRememberMe(true);
subject.login(usernamePasswordToken);
执行到上面的subject.login(usernamePasswordToken);语句时报如下错误:
2018-02-2814:52:50,298ERROR[com.cc.aop.ResponseBodyAround]-
java.lang.NoClassDefFoundError:Couldnotinitializeclasscom.cc.cache.redis.util.RedisSessionUtil
atcom.cc.shiro.session.RedisSessionDAO.doCreate(RedisSessionDAO.java:60)
atorg.apache.shiro.session.mgt.eis.AbstractSessionDAO.create(AbstractSessionDAO.java:116)
atorg.apache.shiro.session.mgt.DefaultSessionManager.create(DefaultSessionManager.java:177)
atorg.apache.shiro.session.mgt.DefaultSessionManager.doCreateSession(DefaultSessionManager.java:158)
atorg.apache.shiro.session.mgt.AbstractValidatingSessionManager.createSession(AbstractValidatingSessionManager.java:136)
atorg.apache.shiro.session.mgt.AbstractNativeSessionManager.start(AbstractNativeSessionManager.java:99)
atorg.apache.shiro.mgt.SessionsSecurityManager.start(SessionsSecurityManager.java:152)
atorg.apache.shiro.subject.support.DelegatingSubject.getSession(DelegatingSubject.java:340)
atorg.apache.shiro.subject.support.DelegatingSubject.getSession(DelegatingSubject.java:316)
atorg.apache.shiro.mgt.DefaultSubjectDAO.mergePrincipals(DefaultSubjectDAO.java:207)
atorg.apache.shiro.mgt.DefaultSubjectDAO.saveToSession(DefaultSubjectDAO.java:165)
atorg.apache.shiro.mgt.DefaultSubjectDAO.save(DefaultSubjectDAO.java:146)
atorg.apache.shiro.mgt.DefaultSecurityManager.save(DefaultSecurityManager.java:387)
atorg.apache.shiro.mgt.DefaultSecurityManager.createSubject(DefaultSecurityManager.java:354)
atorg.apache.shiro.mgt.DefaultSecurityManager.createSubject(DefaultSecurityManager.java:187)
atorg.apache.shiro.mgt.DefaultSecurityManager.login(DefaultSecurityManager.java:287)
atorg.apache.shiro.subject.support.DelegatingSubject.login(DelegatingSubject.java:260)
atcom.cc.xy.action.LoginAction.logon(LoginAction.java:55)
atcom.cc.xy.action.LoginAction$$FastClassBySpringCGLIB$$4c65fff3.invoke()
atorg.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
atorg.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:747)
atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
atorg.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89)
atcom.cc.aop.ResponseBodyAround.processResponseBodyException(ResponseBodyAround.java:43)
atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
atjava.lang.reflect.Method.invoke(Method.java:498)
atorg.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:643)
atorg.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:632)
atorg.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
atorg.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
atorg.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
atcom.cc.xy.action.LoginAction$$EnhancerBySpringCGLIB$$34215121.logon()
atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
atjava.lang.reflect.Method.invoke(Method.java:498)
atorg.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)
atorg.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
atorg.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:871)
atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:777)
atorg.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
atorg.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
atorg.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
atorg.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
atorg.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:881)
atjavax.servlet.http.HttpServlet.service(HttpServlet.java:661)
atorg.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
atjavax.servlet.http.HttpServlet.service(HttpServlet.java:742)
atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
atorg.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
atcom.cc.web.filter.ActionContextFilter.doFilter(ActionContextFilter.java:24)
atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
atorg.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
atorg.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
atorg.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
atorg.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
atorg.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)
atorg.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
atorg.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
atorg.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
atorg.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
atorg.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
atorg.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
atorg.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
atorg.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
atorg.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
atorg.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
atorg.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
atorg.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
atjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
atorg.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
atjava.lang.Thread.run(Thread.java:748)
RedisSessionUtil的代码如下所示:
publicfinalclassRedisSessionUtil{
privatestaticShardedJedisPoolpool=null;
static{
Propertiesp=newProperties();
try{
p.load(RedisSessionUtil.class.getClassLoader().getResourceAsStream("config/session.properties"));
}catch(IOExceptionvar18){
thrownewRuntimeException("config/session.propertiesnotconfig~");
}
StringblockWhenExhausted=p.getProperty("session.blockWhenExhausted");
StringevictionPolicyClassName=p.getProperty("session.evictionPolicyClassName");
StringjmxNamePrefix=p.getProperty("session.jmxNamePrefix");
Stringlifo=p.getProperty("session.lifo");
StringmaxIdle=p.getProperty("session.maxIdle");
StringmaxTotal=p.getProperty("session.maxTotal");
StringmaxWaitMillis=p.getProperty("session.maxWaitMillis");
StringminEvictableIdleTimeMillis=p.getProperty("session.minEvictableIdleTimeMillis");
StringminIdle=p.getProperty("session.minIdle");
StringnumTestsPerEvictionRun=p.getProperty("session.numTestsPerEvictionRun");
StringsoftMinEvictableIdleTimeMillis=p.getProperty("session.softMinEvictableIdleTimeMillis");
StringtestOnBorrow=p.getProperty("session.testOnBorrow");
StringtestOnReturn=p.getProperty("session.testOnReturn");
StringtestWhileIdle=p.getProperty("session.testWhileIdle");
StringtimeBetweenEvictionRunsMillis=p.getProperty("session.timeBetweenEvictionRunsMillis");
JedisPoolConfigpoolConfig=newJedisPoolConfig();
if(StringUtil.isNotEmpty(blockWhenExhausted)){
poolConfig.setBlockWhenExhausted(Boolean.valueOf(blockWhenExhausted).booleanValue());
}
if(StringUtil.isNotEmpty(evictionPolicyClassName)){
poolConfig.setEvictionPolicyClassName(evictionPolicyClassName);
}
if(StringUtil.isNotEmpty(jmxNamePrefix)){
poolConfig.setJmxNamePrefix(jmxNamePrefix);
}
if(StringUtil.isNotEmpty(lifo)){
poolConfig.setLifo(Boolean.valueOf(lifo).booleanValue());
}
if(StringUtil.isNotEmpty(maxIdle)){
poolConfig.setMaxIdle(Integer.parseInt(maxIdle));
}
if(StringUtil.isNotEmpty(maxTotal)){
poolConfig.setMaxTotal(Integer.parseInt(maxTotal));
}
if(StringUtil.isNotEmpty(maxWaitMillis)){
poolConfig.setMaxWaitMillis((long)Integer.parseInt(maxWaitMillis));
}
if(StringUtil.isNotEmpty(minEvictableIdleTimeMillis)){
poolConfig.setMinEvictableIdleTimeMillis(Long.parseLong(minEvictableIdleTimeMillis));
}
if(StringUtil.isNotEmpty(minIdle)){
poolConfig.setMinIdle(Integer.parseInt(minIdle));
}
if(StringUtil.isNotEmpty(numTestsPerEvictionRun)){
poolConfig.setNumTestsPerEvictionRun(Integer.parseInt(numTestsPerEvictionRun));
}
if(StringUtil.isNotEmpty(softMinEvictableIdleTimeMillis)){
poolConfig.setSoftMinEvictableIdleTimeMillis(Long.parseLong(softMinEvictableIdleTimeMillis));
}
if(StringUtil.isNotEmpty(testOnBorrow)){
poolConfig.setTestOnBorrow(Boolean.valueOf(testOnBorrow).booleanValue());
}
if(StringUtil.isNotEmpty(testOnReturn)){
poolConfig.setTestOnReturn(Boolean.valueOf(testOnReturn).booleanValue());
}
if(StringUtil.isNotEmpty(testWhileIdle)){
poolConfig.setTestWhileIdle(Boolean.valueOf(testWhileIdle).booleanValue());
}
if(StringUtil.isNotEmpty(timeBetweenEvictionRunsMillis)){
poolConfig.setTimeBetweenEvictionRunsMillis(Long.parseLong(timeBetweenEvictionRunsMillis));
}
Stringservers=p.getProperty("session.servers");
pool=newShardedJedisPool(poolConfig,JedisShardInfoUtil.getShareInfo(servers));
}
privateRedisSessionUtil(){
}
publicstaticTget(Stringkey){
ShardedJedisshardedJedis=null;
try{
shardedJedis=pool.getResource();
byte[]e=key.getBytes("utf-8");
Objectvalue=SerializeUtil.unserialize(shardedJedis.get(e));
Objectvar5=value;
returnvar5;
}catch(Exceptionvar8){
var8.printStackTrace();
}finally{
if(shardedJedis!=null){
shardedJedis.close();
}
}
returnnull;
}
publicstaticvoidput(Stringkey,Objecto,intexp){
ShardedJedisshardedJedis=null;
try{
shardedJedis=pool.getResource();
byte[]e=key.getBytes("utf-8");
byte[]bValue=SerializeUtil.serialize(o);
shardedJedis.setex(e,exp,bValue);
}catch(Exceptionvar9){
var9.printStackTrace();
}finally{
if(shardedJedis!=null){
shardedJedis.close();
}
}
}
publicstaticvoidput(Stringkey,Objecto){
ShardedJedisshardedJedis=null;
try{
shardedJedis=pool.getResource();
byte[]e=key.getBytes("utf-8");
byte[]bValue=SerializeUtil.serialize(o);
shardedJedis.set(e,bValue);
}catch(Exceptionvar8){
var8.printStackTrace();
}finally{
if(shardedJedis!=null){
shardedJedis.close();
}
}
}
publicstaticvoidremove(Stringkey){
ShardedJedisshardedJedis=null;
try{
shardedJedis=pool.getResource();
byte[]e=key.getBytes("utf-8");
shardedJedis.del(e);
}catch(Exceptionvar6){
var6.printStackTrace();
}finally{
if(shardedJedis!=null){
shardedJedis.close();
}
}
}
publicstaticvoidexpire(Stringkey,intseconds){
ShardedJedisshardedJedis=null;
try{
shardedJedis=pool.getResource();
byte[]e=key.getBytes("utf-8");
shardedJedis.expire(e,seconds);
}catch(Exceptionvar7){
var7.printStackTrace();
}finally{
if(shardedJedis!=null){
shardedJedis.close();
}
}
}
publicstaticSetkeys(Stringkey){
HashSetsets=newHashSet();
ShardedJedisshardedJedis=null;
try{
shardedJedis=pool.getResource();
byte[]e=key.getBytes("utf-8");
Collectionjedises=shardedJedis.getAllShards();
Iteratorvar6=jedises.iterator();
while(var6.hasNext()){
Jedisjedis=(Jedis)var6.next();
Setset=jedis.keys(e);
Iteratorvar9=set.iterator();
while(var9.hasNext()){
byte[]bs=(byte[])var9.next();
Stringk=newString(bs,"utf-8");
sets.add(k);
}
}
}catch(Exceptionvar14){
var14.printStackTrace();
}finally{
if(shardedJedis!=null){
shardedJedis.close();
}
}
returnsets;
}
protectedvoidfinalize()throwsThrowable{
super.finalize();
if(pool!=null){
pool.close();
pool=null;
}
}
}
慕哥9229398
浏览 480回答 2
2回答

墨色风雨

java.lang.NoClassDefFoundError:Couldnotinitializeclasscom.cc.cache.redis.util.RedisSessionUtil...RedisSessionUtil的静态代码块出现异常导致无法初始化,debug一下看看
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript