Redis Unknown redis exception; nested exception is java.lang.ClassCastException


1. 完整错误信息

2020-07-09 14:16:47.579 [XNIO-2 task-58] ERROR com.cargps.controller.sync.LouLanSyncController - Unknown redis exception; nested exception is java.lang.ClassCastException
org.springframework.data.redis.RedisSystemException: Unknown redis exception; nested exception is java.lang.ClassCastException
at org.springframework.data.redis.FallbackExceptionTranslationStrategy.getFallback(FallbackExceptionTranslationStrategy.java:48)
at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:38)
at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:212)
at org.springframework.data.redis.connection.jedis.JedisConnection.exec(JedisConnection.java:764)
at sun.reflect.GeneratedMethodAccessor251.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.data.redis.core.CloseSuppressingInvocationHandler.invoke(CloseSuppressingInvocationHandler.java:57)
at com.sun.proxy.$Proxy270.exec(Unknown Source)
at org.springframework.data.redis.core.RedisTemplate$3.doInRedis(RedisTemplate.java:602)
at org.springframework.data.redis.core.RedisTemplate$3.doInRedis(RedisTemplate.java:600)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:204)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:166)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:154)
at org.springframework.data.redis.core.RedisTemplate.execRaw(RedisTemplate.java:600)
at org.springframework.data.redis.core.RedisTemplate.exec(RedisTemplate.java:587)
at com.cargps.config.cache.RedisUtil.sendMessage(RedisUtil.java:230)
at com.cargps.controller.sync.LouLanSyncController.pushLocationInfo(LouLanSyncController.java:47)
at sun.reflect.GeneratedMethodAccessor393.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.in

2. 源码:

public boolean sendMessage(String channel, Object message) {
boolean result = false;
try {
redisTemplate.convertAndSend(channel, message);
result = true;
} catch (Exception e) {
e.printStackTrace();
}finally {
redisTemplate.multi();
redisTemplate.exec();
RedisConnectionUtils.unbindConnection(redisTemplate.getConnectionFactory());
}
return result;
}

注:redisTemplate 是@autowird 注入进来的。

报错位置: redisTemlate.exec()的时候。

3. 网上有用资源

https://blog.csdn.net/congcong68/article/details/52734735

 

 

4. 临时处理方案:

删除所有的keys,重启Redis,重启服务。

因为是偶发的。所以还没有尝试 网上说的那种方法。

 

望路过的大神指点迷津。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM