0
Caused by: org.springframework.beans.factory.BeanInitializationException: Cannot find region [record] in cache GemFireCache[id = 20255495; 
isClosing = false; isShutDownAll = false;
 closingGatewayHubsByShutdownAll = false; created = Mon Jan 23 11:45:10 EST 2017; server = false; copyOnRead = false; lockLease = 120; lockTimeout = 60]
    at org.springframework.data.gemfire.RegionLookupFactoryBean.lookupFallback(RegionLookupFactoryBean.java:72)
    at org.springframework.data.gemfire.RegionLookupFactoryBean.afterPropertiesSet(RegionLookupFactoryBean.java:59)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
    ... 13 more

My XML File is :

<beans>

    ....

    <context:component-scan base-package="spring.gemfire.repository.deptemp"/>

    <gfe:client-cache id="gemfireCache" pool-name="gfPool"/>

    <!--Region for being used by the Record Bean -->
    <gfe:replicated-region id="record" cache-ref="gemfireCache"/>

    <bean id="record" class="spring.gemfire.repository.deptemp.beans.Record"/>

    <gfe:pool id="gfPool" max-connections="10" subscription-enabled="true" >  
        <gfe:locator host="localhost" port="10334"/>        
    </gfe:pool>   

    <gfe:lookup-region id="record" />  
    <gfe-data:repositories base-package="spring.gemfire.repository.deptemp.repos"/>  

</beans>
John Blum
  • 7,381
  • 1
  • 20
  • 30
abhisekh
  • 1
  • 1

1 Answers1

0

Abhisekh-

Why do you have both this...

<gfe:replicated-region id="record" cache-ref="gemfireCache"/>

And this...

<gfe:lookup-region id="record" />

Also, you have defined this...

<bean id="record" class="spring.gemfire.repository.deptemp.beans.Record"/>

Which (most definitely) overrode your REPLICATE Region bean definition (also with id="record") based on the "order" of your bean definitions in your XML defined above.

While Spring first and foremost adheres to dependency order between bean definitions, it will generally follow the declared order when no dependencies (explicit or implicit) exist.

Since <bean id="record" .../> comes after <gfe:replicated-region id="record" ../>, then <bean id=record../> overrides the <gfe:replicated-region id="record"/> bean definition.

Additionally, the <gfe:lookup-region> is not needed since you are not using GemFire/Geode's native configuration (e.g. cache.xml) or Cluster Configuration Service.

Furthermore, you are declaring a ClientCache, so technically probably want a <gfe:client-region> to match the GemFire/Geode Server Region, yes?!

While you can create REPLICATE Regions (and even PARTITION Regions) on a client, you typically do not do this since those Regions are NOT part of any distributed system, or cluster of GemFire "Server" nodes.

A client Region (which can be a PROXY, or even a CACHING_PROXY) will distribute data operations to the Server. Additionally, if you have data that only a particular client needs, then you ought to create local Regions, using <gfe:local-region>.

I would definitely read this, first...

http://gemfire.docs.pivotal.io/geode/basic_config/book_intro.html

Followed by this next...

http://gemfire.docs.pivotal.io/geode/topologies_and_comm/book_intro.html

Then this...

http://gemfire.docs.pivotal.io/geode/developing/book_intro.html

And lastly...

http://docs.spring.io/spring-data-gemfire/docs/current/reference/html/#bootstrap

-John

srikanth
  • 1,211
  • 2
  • 9
  • 11
John Blum
  • 7,381
  • 1
  • 20
  • 30
  • Hey John - Thanks for your inputs. – abhisekh Jan 23 '17 at 19:18
  • updated cache.xml file and now it it not giving the errors. – abhisekh Jan 24 '17 at 16:01
  • I am using CRUDRepository. public interface RecordRepository extends CrudRepository{ } But, the data is not getting saved in the region after I execute the below code RecordRepository recRepos = ctx.getBean(RecordRepository.class); Record rec1 = new Record(100L,"1","First record"); – abhisekh Jan 24 '17 at 16:04
  • In the eclipse console it is showing as if the Record is getting inserted. 100 1 First record But,the record is not getting inserted in the region. – abhisekh Jan 24 '17 at 16:06
  • query --query="select * from /record" does not returns any result in the gfsh – abhisekh Jan 24 '17 at 16:07
  • You are still using the wrong Region element in SDG's XML namespace if you want your`ClientCache`application to send data from the client to a Region on the GemFire Server (which also must be named "record"). The correct element is ``, otherwise you are effectively creating local-only Regions and the data won't be sent to the server(s) in the cluster hosting the server-side Region and therefore the data will not be visible from Gfsh, however you attempt to access the data (e.g. OQL or otherwise). – John Blum Jan 25 '17 at 22:07