Question

Using Response Object in Jedis, throws ClassCastException . I am not able to get any value from Redis when I use pipeline. Please help. I am using Jedis 2.1.0

public class JedisPipeline {    
    public static void main(String args[]){
        final JedisPool pool = new JedisPool(new JedisPoolConfig(), "127.0.0.1", 6379);
        Jedis jedis = pool.getResource();
        Pipeline pipeline = jedis.pipelined();
        pipeline.multi();
        HashMap<String,String> map = new HashMap<String,String>();
        map.put("50", "50");
        pipeline.hmset("Id",map);
        Response <Long> incr = pipeline.hincrBy("Id", "100", 100);
        Response<Map<String,String>> map1 = pipeline.hgetAll("Id");
        pipeline.exec();
        List<Object> results = pipeline.syncAndReturnAll();
        System.out.println(results);
        System.out.println( incr.get());
        System.out.println( map1.get());
        pool.returnResource(jedis);
        pool.destroy();
    }
}

Exception in thread "main" java.lang.ClassCastException: [B cannot be cast to java.lang.Long
    at redis.clients.jedis.BuilderFactory$4.build(BuilderFactory.java:45)
    at redis.clients.jedis.BuilderFactory$4.build(BuilderFactory.java:48)
    at redis.clients.jedis.Response.get(Response.java:27)
    at redis.clients.jedis.Pipeline.syncAndReturnAll(Pipeline.java:42)
    at com.work.jedis.JedisPipeline.main(JedisPipeline.java:28)
Était-ce utile?

La solution

There was a conflict in the jar files I used. I have kept both jedis 2.1.0 and jedis 2.0.0 by mistake in the build path.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top