0

I am trying to run my Spring Boot application comprise of MongoDB & Redis Server on Virtual Box but getting errors related to redis and hence unable to complete the process..I am getting these Errors :

vb-be7e6bc7 -> Caused by: org.springframework.data.redis.RedisConnectionFailureE
xception: Cannot get Jedis connection; nested exception is redis.clients.jedis.e
xceptions.JedisConnectionException: Could not get a resource from the pool
vb-be7e6bc7 ->  at org.springframework.data.redis.connection.jedis.JedisConnecti
onFactory.fetchJedisConnector(JedisConnectionFactory.java:198) ~[spring-data-red
is-1.7.2.RELEASE.jar!/:na]
vb-be7e6bc7 ->  at org.springframework.data.redis.connection.jedis.JedisConnecti
onFactory.getConnection(JedisConnectionFactory.java:345) ~[spring-data-redis-1.7
.2.RELEASE.jar!/:na]
vb-be7e6bc7 ->  at org.springframework.session.data.redis.config.annotation.web.
http.RedisHttpSessionConfiguration$EnableRedisKeyspaceNotificationsInitializer.a
fterPropertiesSet(RedisHttpSessionConfiguration.java:223) ~[spring-session-1.2.1
.RELEASE.jar!/:na]
vb-be7e6bc7 ->  at org.springframework.beans.factory.support.AbstractAutowireCap
ableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
vb-be7e6bc7 ->  at org.springframework.beans.factory.support.AbstractAutowireCap
ableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[s
pring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
vb-be7e6bc7 ->  ... 24 common frames omitted
vb-be7e6bc7 -> Caused by: redis.clients.jedis.exceptions.JedisConnectionExceptio
n: Could not get a resource from the pool
vb-be7e6bc7 ->  at redis.clients.util.Pool.getResource(Pool.java:53) ~[jedis-2.8
.2.jar!/:na]
vb-be7e6bc7 ->  at redis.clients.jedis.JedisPool.getResource(JedisPool.java:99)
~[jedis-2.8.2.jar!/:na]
vb-be7e6bc7 ->  at redis.clients.jedis.JedisPool.getResource(JedisPool.java:12)
~[jedis-2.8.2.jar!/:na]
vb-be7e6bc7 ->  at org.springframework.data.redis.connection.jedis.JedisConnecti
onFactory.fetchJedisConnector(JedisConnectionFactory.java:191) ~[spring-data-red
is-1.7.2.RELEASE.jar!/:na]
vb-be7e6bc7 ->  ... 28 common frames omitted
vb-be7e6bc7 -> Caused by: redis.clients.jedis.exceptions.JedisConnectionExceptio
n: java.net.ConnectException: Connection refused
vb-be7e6bc7 ->  at redis.clients.jedis.Connection.connect(Connection.java:164) ~
[jedis-2.8.2.jar!/:na]
vb-be7e6bc7 ->  at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:80
) ~[jedis-2.8.2.jar!/:na]
vb-be7e6bc7 ->  at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1677
) ~[jedis-2.8.2.jar!/:na]
vb-be7e6bc7 ->  at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java
:87) ~[jedis-2.8.2.jar!/:na]
vb-be7e6bc7 ->  at org.apache.commons.pool2.impl.GenericObjectPool.create(Generi
cObjectPool.java:868) ~[commons-pool2-2.4.2.jar!/:2.4.2]
vb-be7e6bc7 ->  at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(
GenericObjectPool.java:435) ~[commons-pool2-2.4.2.jar!/:2.4.2]
vb-be7e6bc7 ->  at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(
GenericObjectPool.java:363) ~[commons-pool2-2.4.2.jar!/:2.4.2]
vb-be7e6bc7 ->  at redis.clients.util.Pool.getResource(Pool.java:49) ~[jedis-2.8
.2.jar!/:na]
vb-be7e6bc7 ->  ... 31 common frames omitted
vb-be7e6bc7 -> Caused by: java.net.ConnectException: Connection refused
vb-be7e6bc7 ->  at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.
8.0-8u102]
vb-be7e6bc7 ->  at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocke
tImpl.java:350) ~[na:1.8.0-8u102]
vb-be7e6bc7 ->  at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPla
inSocketImpl.java:206) ~[na:1.8.0-8u102]
vb-be7e6bc7 ->  at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketI
mpl.java:188) ~[na:1.8.0-8u102]
vb-be7e6bc7 ->  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[
na:1.8.0-8u102]
vb-be7e6bc7 ->  at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0-8u102]
vb-be7e6bc7 ->  at redis.clients.jedis.Connection.connect(Connection.java:158) ~
[jedis-2.8.2.jar!/:na]
vb-be7e6bc7 ->  ... 38 common frames omitted

I have tried the following but didn't worked :

Community
  • 1
  • 1
CandleCoder
  • 1,387
  • 4
  • 21
  • 45

1 Answers1

1

Looks like a connection issue, Verify the following:

Configurations mismatch

In your redis redis.conf file locate the bind config and port default to

bind 127.0.0.1
port 6379

The defaults of jedis used by the JedisConnectionFactory (see your stack-trace) are:

bind localhost
port 6379

See the jedis client Protocol and Spring data JedisConnectionFactory classes.

Make sure those match your spring-boot application configurations if not use JedisShardInfo to update your configurations, JedisConnectionFactory accept JedisShardInfo in it’s constractor.

Make sure that your /etc/hosts or c:\windows\system32\drivers\etc\hosts has the entry

127.0.0.1       localhost

Altough trivail sometimes someone chage or delete this.

Redis startup failure

Make sure that your redis is up and running maybe a different process is using the redis port. Use

netstat –anp | grep 6379

or windows

netstat –ano | find “6379”

If you find the other process using the port adjust accordingly

see also What can be the reasons of connection refused errors?

Community
  • 1
  • 1
Haim Raman
  • 11,508
  • 6
  • 44
  • 70
  • Can you provide your spring-boot configurations? – Haim Raman Nov 21 '16 at 06:43
  • buildscript { ext { springBootVersion = '1.4.0.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'spring-boot' jar { baseName = 'service' version = '0.0.1-SNAPSHOT' } sourceCompatibility = 1.8 targetCompatibility = 1.8 repositories { mavenCentral() } – CandleCoder Nov 21 '16 at 07:00
  • dependencies { compile('org.springframework.boot:spring-boot-starter-data-mongodb') compile('org.springframework.boot:spring-boot-starter-jersey') compile('org.projectlombok:lombok') compile("org.springframework.boot:spring-boot-devtools") //auto reload compile ('org.springframework.session:spring-session-data-redis') testCompile('org.springframework.boot:spring-boot-starter-test') } – CandleCoder Nov 21 '16 at 07:01