0

I am trying read locator host and port information from JNDI whose value is in the format host[port],host2[port2].

<jee:jndi-lookup id="locatorsJndi" jndi-name="locators/locator1" />
<gfe:pool id="locatorPool" locators="#{locatorsJndi}">

It seems Spring Data gemfire unable to identify locators correctly in this case. It is taking JNDI lookuped value string as one host and is appending port 10334 at the end.

Unable to connect to any locators in the list [**host[10334],host2[10334]**:10334]; nested exception is com.gemstone.gemfire.cache.client.NoAvailableLocatorsException:

But, if i pass host and port values as part of locators attribute as below, it is working as expected.

<gfe:pool id="locatorPool" locators="host1[port1],host2[port2]">

Is this an issue in Spring Data Gemfire?.

nageshb20
  • 3
  • 3

2 Answers2

0

Since the underlying exception is NoAvailableLocatorsException, can you please try connecting to the locators from gfsh to see if that succeeds?

gfsh>connect --locator=host1[port1]
Swapnil
  • 1,191
  • 7
  • 8
  • I suspect the Locators are fine since he says... "But, if i pass host and port values as part of locators, it is working as expected." I can see that the Locators String is not correct. Adding additional answer now. – John Blum Sep 27 '16 at 18:59
0

Unable to connect to any locators in the list "host[10334],host2[10334]:10334]";

The host/port, comma-delimited String from the Stack Trace message is not correct.

I gather your configuration of the GemFire Locators in your JNDI context is correctly specified as... "host[10334],host2[10334]"?

If so, then this boils down to the simple fact that Spring Data GemFire does not properly, or rather currently, handle SpEL expressions in the locators and servers attributes of the <gfe:pool> XML namespace element based bean definitions.

It does, however, handle Spring property placeholders, as in...

<gfe:pool id="locatorsPool" locators="${app.gemfire.locators}"/>

It is a rather long and complex explanation to understand why the current behavior is what it is, but certainly this could be improved. So, I have filed SGF-535.

NOTE: I fixed a similar issue in the PoolParser when property placeholders were specified with the locators and servers attributes in SGF-433.

To workaround this issue, you can do the following...

<jee:jndi-lookup id="locatorsJndi" jndi-name="locators/locator1"/>

<util:properties id="applicationProperties">
  <prop key="locators">#{locatorsJndi}</prop>
</util:properties>

<context:property-placeholder properties-ref="applicationProperties"/>

<gfe:pool id="locatorPool" locators="${locators}"/>

Follow SGF-535 for updates on my progress.

Sorry for the inconvenience,

John

John Blum
  • 7,381
  • 1
  • 20
  • 30
  • Thanks John for your quick response. I tried your work around. I am getting following error now. It does not say much about why it is not able to create locatorPool. Caused by: java.lang.IllegalStateException: The connection pool "locatorPool" has not been created. – nageshb20 Sep 27 '16 at 23:07
  • Hi @nagesh20- Can you update your SO post and paste the new Exception? The code snippet I gave you should have worked without incident. – John Blum Sep 29 '16 at 05:16
  • Just an update... I resolved/completed SGF-535 (https://jira.spring.io/browse/SGF-535). Also, the SD team will be releasing SDG 1.7.6.RELEASE (Gosling SR6) and SDG 1.8.4.RELEASE (Hopper SR4) tomorrow, and changes for SGF-535 will go out in these releases. Hopefully, you are using either a 1.7.x or 1.8.x. If not, I recommend that you upgrade given SDG 1.6 and earlier are no longer supported. If you have additional questions or comments, let me know. Cheers! – John Blum Sep 29 '16 at 05:18
  • Hi @nageshb20 - For your reference... here is a test class from SDG's test suite that illustrates the use of both Spring property placeholders and SpEL expressions... https://github.com/spring-projects/spring-data-gemfire/blob/1.8.4.RELEASE/src/test/java/org/springframework/data/gemfire/client/PoolsConfiguredWithLocatorsAndServersExpressionsIntegrationTests.java. XML config file... https://github.com/spring-projects/spring-data-gemfire/blob/1.8.4.RELEASE/src/test/resources/org/springframework/data/gemfire/client/PoolsConfiguredWithLocatorsAndServersExpressionsIntegrationTests-context.xml – John Blum Sep 29 '16 at 15:51
  • Thanks John. I shall check with latest version. – nageshb20 Oct 11 '16 at 23:23