title: Cannot get connection for redisTemplate for Spring data redis
body: <p>I'm trying to publish a message to a channel using Spring data Redis using Jedis. Here is a very simple Java config:</p>
  
  <pre><code>@Bean(name="jedisConnectionFactory")
  JedisConnectionFactory jedisConnectionFactory() {
      JedisConnectionFactory factory = new JedisConnectionFactory();
      factory.setHostName(redisHostName);
      factory.setPort(redisPort);
      factory.setUsePool(true);
      return factory;
  }
  
  @Bean(name="redisTemplate")
  RedisTemplate&lt;Object, Object&gt; redisTemplate() {
      RedisTemplate&lt;Object, Object&gt; redisTemplate = new RedisTemplate&lt;Object, Object&gt;();
      redisTemplate.setConnectionFactory(jedisConnectionFactory());
      return redisTemplate;
  }
  </code></pre>
  
  <p>where redisPort=6379 and redisHostName="localhost".</p>
  
  <p>When I run the following test:</p>
  
  <pre><code> @Test
  public void testRedis(){
      ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
      RedisTemplate&lt;Object,Object&gt; redisTemplate = (RedisTemplate&lt;Object, Object&gt;) context.getBean("redisTemplate");
      redisTemplate.convertAndSend("test", "123");
  }
  </code></pre>
  
  <p>I get the following stacktrace:</p>
  
  <pre><code>java.lang.ExceptionInInitializerError
  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.RedisTemplate.convertAndSend(RedisTemplate.java:676)
  at com.jobvite.realtimeanalytics.redis.RedisTest.testRedis(RedisTest.java:22)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:73)
  at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
  at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:224)
  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
  at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
  at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:68)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:163)
  at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
  at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
  at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
  at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
  at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
  at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
  at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) 
  Caused by: java.lang.NullPointerException
  at org.springframework.util.ReflectionUtils.makeAccessible(ReflectionUtils.java:443)
  at org.springframework.data.redis.connection.jedis.JedisConnection.&lt;clinit&gt;(JedisConnection.java:108)
  ... 44 more
  </code></pre>