0

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>
ragnor
  • 2,498
  • 1
  • 22
  • 25
mns
  • 329
  • 4
  • 18

1 Answers1

0

Show your configuration and usage.

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

ragnor
  • 2,498
  • 1
  • 22
  • 25
  • I have done both. Updated the question with my config. I do use "value" parameter. Without value param set, i got different exceptions saying cachename is not known. – mns Jun 15 '15 at 05:37
  • As we discussed on SSM email group make sure that a correct and valid configuration is used for DefaultAddressProvider. The one that you have post are invalid because it points to local memcached but should to AWS server. – ragnor Jun 15 '15 at 09:30
  • The problem was indeed that it was picking up the default address provider instead of the AWS specifics that I had given. Fixing that solved the problem. Thanks a lot – mns Jun 17 '15 at 06:21