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