zoukankan      html  css  js  c++  java
  • 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,重启服务。

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

    望路过的大神指点迷津。

  • 相关阅读:
    【分享】HTML5附件拖拽上传drop & google.gears
    【分享】return false,对阻止事件默认动作的一些测试
    【记录】随笔分类汇总
    【分享】微博 @ 符号的用户名提示效果。(想@到谁?)
    【记录】File, FileReader 和 Ajax 文件上传
    【动态】简单的JS动态加载单体
    【分享】简单页面提示插件第二版表单验证很简单
    【记录】GIT 常用命令
    【分享】jQuery animate自定义动画的简单实现
    【分享】 封装js操作textarea 方法集合(兼容很好)。
  • 原文地址:https://www.cnblogs.com/baoyi/p/redis_error.html
Copyright © 2011-2022 走看看