0

I'm using to redis in spring mvc based web application. so I used spring-data-redis & jedis. The library version is the following. Spring MVC 4.1.6 jedis 3.0 Spring data redis 1.6 SNAPSHOT Redis Server 3.0.2 (installed on Cent OS 7)

Application configuration is following:

-spring configuration xml(applicationContext.xml)

<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
    <property name="maxWaitMillis" value="3000"/>
    <property name="maxTotal" value="50"/>
    <property name="testOnBorrow" value="true"/>
</bean>
<bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
    p:database="16" p:usePool="true"
    p:poolConfig-ref="jedisPoolConfig" p:host-name="${redis.host}" p:port="${redis.port}" p:password="${redis.pass}"/>

<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" p:connectionFactory-ref="connectionFactory" />

-RedisServices.java

public interface RedisServices {
    List getAppInfos();
    void add_appinfo(List data);
}

-RedisServicesImpl.java

@Service
public class RedisServicesImpl implements RedisServices{
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;
    @Resource(name="redisTemplate")
    private ValueOperations<String, Object> valueOps;

    @Override
    public List getAppInfos() {
        return (List)valueOps.get(Constants.APP_INFO_KEY);
    }

    @Override
    public void add_appinfo(List data) {
        valueOps.set(Constants.APP_INFO_KEY, data);
    }

}

- AppController.java

@RestController
@RequestMapping(value = "/appinfo")
public class AppsController {
    @Autowired
    private RedisServices redis;

    @RequestMapping(value = "/mobiles",method = RequestMethod.GET)
    public List view_apps_register(){
        List data=new ArrayList();
        List lst=services.view_app_register(apps);
        for (int i = 0; i < lst.size(); i++) {
            Map ap = (Map) lst.get(i);
            String server=(String) ap.get("server");
            if(server.equals(apps)){
                data.add(ap);
            }
        }
        redis.add_appinfo(data);
        return null;
    }
}

The following errors raised

java.lang.IllegalAccessError: tried to access method redis.clients.util.Pool.returnResource(Ljava/lang/Object;)V from class org.springframework.data.redis.connection.jedis.JedisConnection
    at org.springframework.data.redis.connection.jedis.JedisConnection.close(JedisConnection.java:251)
    at org.springframework.data.redis.connection.jedis.JedisConnection.<init>(JedisConnection.java:184)
    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:252)
    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:58)
    at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:128)
    at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:91)
    at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:78)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:178)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:153)
    at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:86)
    at org.springframework.data.redis.core.DefaultValueOperations.set(DefaultValueOperations.java:169)
    at com.wwzz.services.redis.RedisServicesImpl.add_appinfo(RedisServicesImpl.java:63)

Help me!!!!

Zin Zu
  • 1
  • 2
  • 2
    Jedis 3.0 has not been released so far. The development branch for that version contains breaking changes (such changing visibility of operations on the Pool) and overall resource handling in jedis... Is there a special reason to depend on snapshots anyway? – Christoph Strobl Jul 01 '15 at 07:14
  • Please not to expect Spring-data-redis can work with snapshot version of Jedis. If you really need to use Jedis 3.0.0 SNAPSHOT, please use it alone. Thanks for experimenting our master branch. – Jungtaek Lim Jul 09 '15 at 04:13

0 Answers0