title: Cannot use Jedis when in Multi. Please use JedisTransaction instead
body: <p>Hi I am using redis with spring and implementing it using @Cacheable.
  Below is my spring and redis versions:</p>
  
  <p>Redis: 
  spring-data-redis 1.5.0.RELEASE
  jedis 2.6.1</p>
  
  <p>Spring: 4.1.1.RELEASE</p>
  
  <p>Below is my redis configuration.</p>
  
  <pre><code>import java.util.Arrays;
  
  import org.apache.log4j.Logger;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.cache.CacheManager;
  import org.springframework.cache.annotation.CachingConfigurerSupport;
  import org.springframework.cache.annotation.EnableCaching;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.data.redis.cache.RedisCacheManager;
  import org.springframework.data.redis.connection.RedisConnectionFactory;
  import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
  import org.springframework.data.redis.core.RedisTemplate;
  import org.springframework.data.redis.serializer.RedisSerializer;
  import org.springframework.data.redis.serializer.StringRedisSerializer;
  
  import redis.clients.jedis.JedisPoolConfig;
  
  @Configuration
  @EnableCaching
  public class CacheConfig extends CachingConfigurerSupport {
  
      private static final Logger log = Logger.getLogger(CacheConfig.class);
  
      @Autowired
      RedisConfig redisConfig;
  
      @Bean
      public JedisConnectionFactory redisConnectionFactory() {
          JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
  
          JedisPoolConfig config = new JedisPoolConfig();
          config.setMaxTotal(1000);
          config.setMaxIdle(10);
          config.setMinIdle(1);
          config.setMaxWaitMillis(30000);
  
          // Defaults
          redisConnectionFactory.setHostName(redisConfig.getRedisHost());
          redisConnectionFactory.setPort(redisConfig.getRedisPort());
          redisConnectionFactory.setDatabase(redisConfig.getRedisDatabase());
          redisConnectionFactory.setPoolConfig(config);
          redisConnectionFactory.setUsePool(true);
  
          return redisConnectionFactory;
      }
  
      @Bean
      public StringRedisSerializer redisSerializer() {
          StringRedisSerializer redisSerializer = new StringRedisSerializer();
  
          return redisSerializer;
      }
  
      @Bean
      public RedisTemplate&lt;String, String&gt; redisTemplate(JedisConnectionFactory cf, RedisSerializer sl) {
          RedisTemplate&lt;String, String&gt; redisTemplate = new RedisTemplate&lt;String, String&gt;();
          redisTemplate.setConnectionFactory(cf);
          redisTemplate.setKeySerializer(sl);
          redisTemplate.setHashKeySerializer(sl);
          redisTemplate.setEnableTransactionSupport(true);
  
          return redisTemplate;
      }
  
      @Bean
      public CacheManager cacheManager(RedisTemplate redisTemplate) {
          RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate);
  
          // Number of seconds before expiration. Defaults to unlimited (0)
          cacheManager.setDefaultExpiration(3600);
          cacheManager.setCacheNames(Arrays.asList("my-cache"));
          cacheManager.setTransactionAware(true);
          cacheManager.setLoadRemoteCachesOnStartup(true);
          cacheManager.setUsePrefix(true);
          return cacheManager;
      }
  
  }
  </code></pre>
  
  <p>However I am getting following exception on running the code:</p>
  
  <pre><code>org.springframework.dao.InvalidDataAccessApiUsageException: Cannot use Jedis when in Multi. Please use JedisTransaction instead.; nested exception is redis.clients.jedis.exceptions.JedisDataException: Cannot use Jedis when in Multi. Please use JedisTransaction instead.
      at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:44)
      at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:36)
      at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:37)
      at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:37)
      at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:196)
      at org.springframework.data.redis.connection.jedis.JedisConnection.close(JedisConnection.java:253)
      at org.springframework.data.redis.core.RedisConnectionUtils.unbindConnection(RedisConnectionUtils.java:230)
      at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:203)
      at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:153)
      at org.springframework.data.redis.cache.RedisCache.put(RedisCache.java:140)
      at org.springframework.data.redis.cache.RedisCache.put(RedisCache.java:125)
      at org.springframework.cache.transaction.TransactionAwareCacheDecorator.put(TransactionAwareCacheDecorator.java:85)
      at org.springframework.cache.interceptor.AbstractCacheInvoker.doPut(AbstractCacheInvoker.java:82)
      at org.springframework.cache.interceptor.CacheAspectSupport$CachePutRequest.apply(CacheAspectSupport.java:651)
      at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:358)
      at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:299)
      at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
  </code></pre>
  
  <p>Please suggest me if I am doing anything wrong.</p>
  
  <p>EDIT: Service Class implementation.</p>
  
  <pre><code>import java.util.List;
  
  import org.apache.log4j.Logger;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.cache.annotation.Cacheable;
  import org.springframework.stereotype.Service;
  import org.springframework.transaction.annotation.Transactional;
  
  @Service
  public class LocationMasterService implements ILocationMasterService {
      private final Logger logger = Logger.getLogger(getClass());
  
      @Autowired
      ILocationMasterDao locationMasterDao;
  
      @Override
      @Cacheable(value = "my-cache", key = "#root.methodName")
      public List&lt;LocationMasterResponse&gt; getLocation() {
          logger.debug("Inside StoreMasterService createStore action ");
          List&lt;LocationMasterResponse&gt; locationList = null;
  
          List&lt;LocationMasterEntity&gt; locationMasterEntityList = null;
          locationMasterEntityList = locationMasterDao.getLocation();
  
          locationList = MapperUtil.map(locationMasterEntityList, LocationMasterResponse.class);
  
  
          return locationList;
      }
  
  }
  </code></pre>