java.net.ConnectException: Connection refused

Spring JIRA | John Blum | 1 year ago
  1. 0

    Currently, the resolution of Spring property placeholders in the {{<gfe:pool>}}, "{{locators}}" and "{{servers}}" attributes does not function properly since the logic to parse the value of a particular property placeholder is misplaced. The logic parsing the attribute values is inappropriately placed in the [PoolParser|https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/config/PoolParser.java]. Specifically, the following [lines of code|https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/config/PoolParser.java#L81-L82] initiate the parsing of the "{{locators}}" and "{{servers}}" attributes, respectively. This leads to the following calls for [locators|https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/config/PoolParser.java#L168-L170] and [servers|https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/config/PoolParser.java#L181-L183], respectively. However, by the time the Thread of execution reaches the code to [parse a connection|https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/config/PoolParser.java#L137-L152], the value of the '{{hostPort}}' combo is actually the Spring property placeholder and not the value of the property placeholder. This leads to the following Exception at runtime when the client attempts to connect to the server using the configured GemFire Pool... {code:java} com.gemstone.gemfire.cache.client.NoAvailableLocatorsException: Unable to connect to any locators in the list [localhost[11235]:10334] at com.gemstone.gemfire.cache.client.internal.AutoConnectionSourceImpl.findServer(AutoConnectionSourceImpl.java:136) at com.gemstone.gemfire.cache.client.internal.ConnectionFactoryImpl.createClientToServerConnection(ConnectionFactoryImpl.java:206) at com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl.borrowConnection(ConnectionManagerImpl.java:214) at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:134) at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:113) at com.gemstone.gemfire.cache.client.internal.PoolImpl.execute(PoolImpl.java:702) at com.gemstone.gemfire.cache.client.internal.GetOp.execute(GetOp.java:94) at com.gemstone.gemfire.cache.client.internal.ServerRegionProxy.get(ServerRegionProxy.java:133) at com.gemstone.gemfire.internal.cache.LocalRegion.findObjectInSystem(LocalRegion.java:2739) at com.gemstone.gemfire.internal.cache.LocalRegion.nonTxnFindObject(LocalRegion.java:1464) at com.gemstone.gemfire.internal.cache.LocalRegionDataView.findObject(LocalRegionDataView.java:133) at com.gemstone.gemfire.internal.cache.LocalRegion.get(LocalRegion.java:1348) at com.gemstone.gemfire.internal.cache.LocalRegion.get(LocalRegion.java:1311) at com.gemstone.gemfire.internal.cache.LocalRegion.get(LocalRegion.java:1298) at com.gemstone.gemfire.internal.cache.AbstractRegion.get(AbstractRegion.java:321) ... {code} And more specifically... {code:java} java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:579) at com.gemstone.gemfire.internal.SocketUtils.connect(SocketUtils.java:88) at com.gemstone.gemfire.internal.SocketUtils.connect(SocketUtils.java:60) at com.gemstone.gemfire.internal.SocketCreator.connect(SocketCreator.java:1011) at com.gemstone.gemfire.internal.SocketCreator.connect(SocketCreator.java:946) at com.gemstone.gemfire.internal.SocketCreator.connect(SocketCreator.java:936) at com.gemstone.org.jgroups.stack.tcpserver.TcpClient.getServerVersion(TcpClient.java:163) at com.gemstone.org.jgroups.stack.tcpserver.TcpClient.requestToServer(TcpClient.java:90) at com.gemstone.org.jgroups.stack.tcpserver.TcpClient.requestToServer(TcpClient.java:78) at com.gemstone.gemfire.cache.client.internal.AutoConnectionSourceImpl.queryOneLocator(AutoConnectionSourceImpl.java:188) at com.gemstone.gemfire.cache.client.internal.AutoConnectionSourceImpl.queryLocators(AutoConnectionSourceImpl.java:220) at com.gemstone.gemfire.cache.client.internal.AutoConnectionSourceImpl.findServer(AutoConnectionSourceImpl.java:132) at com.gemstone.gemfire.cache.client.internal.ConnectionFactoryImpl.createClientToServerConnection(ConnectionFactoryImpl.java:206) at com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl.prefillConnection(ConnectionManagerImpl.java:794) at com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl.prefill(ConnectionManagerImpl.java:737) at com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl$PrefillConnectionsTask.run2(ConnectionManagerImpl.java:888) at com.gemstone.gemfire.cache.client.internal.PoolImpl$PoolTask.run(PoolImpl.java:1249) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) {code}

    Spring JIRA | 1 year ago | John Blum
    java.net.ConnectException: Connection refused
  2. 0

    Currently, the resolution of Spring property placeholders in the {{<gfe:pool>}}, "{{locators}}" and "{{servers}}" attributes does not function properly since the logic to parse the value of a particular property placeholder is misplaced. The logic parsing the attribute values is inappropriately placed in the [PoolParser|https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/config/PoolParser.java]. Specifically, the following [lines of code|https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/config/PoolParser.java#L81-L82] initiate the parsing of the "{{locators}}" and "{{servers}}" attributes, respectively. This leads to the following calls for [locators|https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/config/PoolParser.java#L168-L170] and [servers|https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/config/PoolParser.java#L181-L183], respectively. However, by the time the Thread of execution reaches the code to [parse a connection|https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/config/PoolParser.java#L137-L152], the value of the '{{hostPort}}' combo is actually the Spring property placeholder and not the value of the property placeholder. This leads to the following Exception at runtime when the client attempts to connect to the server using the configured GemFire Pool... {code:java} com.gemstone.gemfire.cache.client.NoAvailableLocatorsException: Unable to connect to any locators in the list [localhost[11235]:10334] at com.gemstone.gemfire.cache.client.internal.AutoConnectionSourceImpl.findServer(AutoConnectionSourceImpl.java:136) at com.gemstone.gemfire.cache.client.internal.ConnectionFactoryImpl.createClientToServerConnection(ConnectionFactoryImpl.java:206) at com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl.borrowConnection(ConnectionManagerImpl.java:214) at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:134) at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:113) at com.gemstone.gemfire.cache.client.internal.PoolImpl.execute(PoolImpl.java:702) at com.gemstone.gemfire.cache.client.internal.GetOp.execute(GetOp.java:94) at com.gemstone.gemfire.cache.client.internal.ServerRegionProxy.get(ServerRegionProxy.java:133) at com.gemstone.gemfire.internal.cache.LocalRegion.findObjectInSystem(LocalRegion.java:2739) at com.gemstone.gemfire.internal.cache.LocalRegion.nonTxnFindObject(LocalRegion.java:1464) at com.gemstone.gemfire.internal.cache.LocalRegionDataView.findObject(LocalRegionDataView.java:133) at com.gemstone.gemfire.internal.cache.LocalRegion.get(LocalRegion.java:1348) at com.gemstone.gemfire.internal.cache.LocalRegion.get(LocalRegion.java:1311) at com.gemstone.gemfire.internal.cache.LocalRegion.get(LocalRegion.java:1298) at com.gemstone.gemfire.internal.cache.AbstractRegion.get(AbstractRegion.java:321) ... {code} And more specifically... {code:java} java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:579) at com.gemstone.gemfire.internal.SocketUtils.connect(SocketUtils.java:88) at com.gemstone.gemfire.internal.SocketUtils.connect(SocketUtils.java:60) at com.gemstone.gemfire.internal.SocketCreator.connect(SocketCreator.java:1011) at com.gemstone.gemfire.internal.SocketCreator.connect(SocketCreator.java:946) at com.gemstone.gemfire.internal.SocketCreator.connect(SocketCreator.java:936) at com.gemstone.org.jgroups.stack.tcpserver.TcpClient.getServerVersion(TcpClient.java:163) at com.gemstone.org.jgroups.stack.tcpserver.TcpClient.requestToServer(TcpClient.java:90) at com.gemstone.org.jgroups.stack.tcpserver.TcpClient.requestToServer(TcpClient.java:78) at com.gemstone.gemfire.cache.client.internal.AutoConnectionSourceImpl.queryOneLocator(AutoConnectionSourceImpl.java:188) at com.gemstone.gemfire.cache.client.internal.AutoConnectionSourceImpl.queryLocators(AutoConnectionSourceImpl.java:220) at com.gemstone.gemfire.cache.client.internal.AutoConnectionSourceImpl.findServer(AutoConnectionSourceImpl.java:132) at com.gemstone.gemfire.cache.client.internal.ConnectionFactoryImpl.createClientToServerConnection(ConnectionFactoryImpl.java:206) at com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl.prefillConnection(ConnectionManagerImpl.java:794) at com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl.prefill(ConnectionManagerImpl.java:737) at com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl$PrefillConnectionsTask.run2(ConnectionManagerImpl.java:888) at com.gemstone.gemfire.cache.client.internal.PoolImpl$PoolTask.run(PoolImpl.java:1249) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) {code}

    Spring JIRA | 1 year ago | John Blum
    java.net.ConnectException: Connection refused
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0
    Check if your MongoDB is available.
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.net.ConnectException

    Connection refused

    at java.net.PlainSocketImpl.socketConnect()
  2. Java RT
    Socket.connect
    1. java.net.PlainSocketImpl.socketConnect(Native Method)
    2. java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    3. java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    4. java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    5. java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    6. java.net.Socket.connect(Socket.java:579)
    6 frames
  3. com.gemstone.gemfire
    SocketCreator.connect
    1. com.gemstone.gemfire.internal.SocketUtils.connect(SocketUtils.java:88)
    2. com.gemstone.gemfire.internal.SocketUtils.connect(SocketUtils.java:60)
    3. com.gemstone.gemfire.internal.SocketCreator.connect(SocketCreator.java:1011)
    4. com.gemstone.gemfire.internal.SocketCreator.connect(SocketCreator.java:946)
    5. com.gemstone.gemfire.internal.SocketCreator.connect(SocketCreator.java:936)
    5 frames
  4. com.gemstone.org
    TcpClient.requestToServer
    1. com.gemstone.org.jgroups.stack.tcpserver.TcpClient.getServerVersion(TcpClient.java:163)
    2. com.gemstone.org.jgroups.stack.tcpserver.TcpClient.requestToServer(TcpClient.java:90)
    3. com.gemstone.org.jgroups.stack.tcpserver.TcpClient.requestToServer(TcpClient.java:78)
    3 frames
  5. com.gemstone.gemfire
    PoolImpl$PoolTask.run
    1. com.gemstone.gemfire.cache.client.internal.AutoConnectionSourceImpl.queryOneLocator(AutoConnectionSourceImpl.java:188)
    2. com.gemstone.gemfire.cache.client.internal.AutoConnectionSourceImpl.queryLocators(AutoConnectionSourceImpl.java:220)
    3. com.gemstone.gemfire.cache.client.internal.AutoConnectionSourceImpl.findServer(AutoConnectionSourceImpl.java:132)
    4. com.gemstone.gemfire.cache.client.internal.ConnectionFactoryImpl.createClientToServerConnection(ConnectionFactoryImpl.java:206)
    5. com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl.prefillConnection(ConnectionManagerImpl.java:794)
    6. com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl.prefill(ConnectionManagerImpl.java:737)
    7. com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl$PrefillConnectionsTask.run2(ConnectionManagerImpl.java:888)
    8. com.gemstone.gemfire.cache.client.internal.PoolImpl$PoolTask.run(PoolImpl.java:1249)
    8 frames
  6. Java RT
    Thread.run
    1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    3. java.lang.Thread.run(Thread.java:745)
    3 frames