"client not initialized" error when using SSMCache with AWS elasticache autodiscovery

1.5k views Asked by At

I am using Spring cache with AWS elasticache provider. I get this warning:

WARN c.g.code.ssm.spring.SSMCache - An error has occurred for cache defaultCache and key 

java.lang.IllegalStateException: Client is not initialized
    at net.spy.memcached.MemcachedClient.checkState(MemcachedClient.java:1623) ~[elasticache-java-cluster-client.jar:na]
    at net.spy.memcached.MemcachedClient.enqueueOperation(MemcachedClient.java:1617) ~[elasticache-java-cluster-client.jar:na]
    at net.spy.memcached.MemcachedClient.asyncGet(MemcachedClient.java:1013) ~[elasticache-java-cluster-client.jar:na]
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1235) ~[elasticache-java-cluster-client.jar:na]
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1256) ~[elasticache-java-cluster-client.jar:na]
    at com.google.code.ssm.providers.elasticache.MemcacheClientWrapper.get(MemcacheClientWrapper.java:147) ~[aws-elasticache-provider.jar:na]
    at com.google.code.ssm.CacheImpl.get(CacheImpl.java:271) ~[simple-spring-memcached.jar:na]
    at com.google.code.ssm.CacheImpl.get(CacheImpl.java:106) ~[simple-spring-memcached.jar:na]
    at com.google.code.ssm.spring.SSMCache.getValue(SSMCache.java:226) [spring-cache.jar:na]
    at com.google.code.ssm.spring.SSMCache.get(SSMCache.java:100) [spring-cache.jar:na]

I am using the same memcache without spring cache and it works fine. I get this error only when I use spring cache.

I have verified that the security groups has the Inbound port specified and I am running my code on EC2.

UPDATE 1:

adding my config -

<bean name="cacheManager" class="com.google.code.ssm.spring.SSMCacheManager">
    <property name="caches">
            <set>
                    <bean class="com.google.code.ssm.spring.SSMCache">
                            <constructor-arg name="cache" index="0" ref="defaultMemcachedClient" />
                            <!-- 5 minutes -->
                            <constructor-arg name="expiration" index="1" value="3600" />
                            <!-- @CacheEvict(..., "allEntries" = true) won't work because allowClear is false, 
                            so we won't flush accidentally all entries from memcached instance -->
                            <constructor-arg name="allowClear" index="2" value="false" />
                    </bean>
            </set>
    </property>
    </bean>

    <bean name="defaultMemcachedClient" class="com.google.code.ssm.CacheFactory">
            <property name="cacheName" value="defaultCache" />
    <property name="cacheClientFactory">
            <bean name="cacheClientFactory" class="com.google.code.ssm.providers.elasticache.MemcacheClientFactoryImpl" />
    </property>
            <property name="addressProvider">
            <bean class="com.google.code.ssm.config.DefaultAddressProvider">
                    <property name="address" value="127.0.0.1:11211" />
            </bean>
    </property>
    <property name="configuration">
            <bean class="com.google.code.ssm.providers.elasticache.ElastiCacheConfiguration">
                    <property name="consistentHashing" value="true" />
                    <property name="clientMode" value="#{T(net.spy.memcached.ClientMode).Dynamic}" />
            </bean>
    </property>
    </bean>
1

There are 1 answers

3
ragnor On BEST ANSWER

Show your configuration and usage.

It seams that you haven't defined defaultCache or used Cacheable without 'value' param set.