0

I'm getting to introduced to pivotal GemFire, so I created a starter project in spring and replicated the below project in spring guide.

https://spring.io/guides/gs/accessing-data-gemfire/

And this project is working data is been persisted and I can able to retrieve data as well.

On the other side I have downloaded the "GemFire 8.2.1" and installed in my system and set all env variables and can able to run the conmmandLine for GemFire "gfsh" .

1) Now my question is how to view that persisted data (persisted thru spring-data-gemfire) in this commandline gfsh. so, that I can really see how it is storing and etc.

2) Also, in the above spring project although it working fine its throwing exception as

[info 2016/06/07 20:24:55.559 IST <main> tid=0x1] Command Service could not be initialized. Could not find Spring Shell library which is needed for CLI/gfsh in classpath. Internal support for CLI & gfsh is not enabled. Note: For convenience, absolute path of "gfsh-dependencies.jar" from "lib" directory of GemFire product distribution can be included in CLASSPATH of an application.
com.gemstone.gemfire.management.DependenciesNotFoundException: Could not find Spring Shell library which is needed for CLI/gfsh in classpath. Internal support for CLI & gfsh is not enabled. Note: For convenience, absolute path of "gfsh-dependencies.jar" from "lib" directory of GemFire product distribution can be included in CLASSPATH of an application.
    at com.gemstone.gemfire.management.cli.CommandService.createLocalCommandService(CommandService.java:135)
    at com.gemstone.gemfire.management.internal.beans.MemberMBeanBridge.<init>(MemberMBeanBridge.java:352)
    at com.gemstone.gemfire.management.internal.beans.ManagementAdapter.handleCacheCreation(ManagementAdapter.java:152)
    at com.gemstone.gemfire.management.internal.beans.ManagementListener.handleEvent(ManagementListener.java:111)
    at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.notifyResourceEventListeners(InternalDistributedSystem.java:2243)
    at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.handleResourceEvent(InternalDistributedSystem.java:503)
    at com.gemstone.gemfire.internal.cache.GemFireCacheImpl.init(GemFireCacheImpl.java:1009)
    at com.gemstone.gemfire.internal.cache.GemFireCacheImpl.create(GemFireCacheImpl.java:682)
    at com.gemstone.gemfire.cache.CacheFactory.create(CacheFactory.java:182)
    at com.gemstone.gemfire.cache.CacheFactory.create(CacheFactory.java:229)
    at org.springframework.data.gemfire.CacheFactoryBean.createCache(CacheFactoryBean.java:398)
    at org.springframework.data.gemfire.CacheFactoryBean.resolveCache(CacheFactoryBean.java:303)
    at org.springframework.data.gemfire.CacheFactoryBean.init(CacheFactoryBean.java:244)
    at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:871)
    at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:86)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1590)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:317)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:464)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:534)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:523)
    at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1162)
    at org.springframework.data.gemfire.repository.support.GemfireRepositoryFactoryBean.setApplicationContext(GemfireRepositoryFactoryBean.java:71)
    at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:119)
    at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:94)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at com.wrd.mytrah.GemFireSubject03Application.main(GemFireSubject03Application.java:26)
```

so how to resolve this , it has anything to do with the above problem (question 1)

Please help to this newbee.. thanks

1 Answers1

2

1) You have a few options for seeing the data persisted to GemFire from your Spring Data GemFire based application using Gfsh.

1.a) You can execute OQL from the gfsh command-line like so...

gfsh>query --query="SELECT * FROM /<your region name here> WHERE <predicates here>"

For example...

SELECT c.name FROM /Customers c WHERE c.age > 21

See the GemFire documentation for more details...

1.b) You also have the option of using GemFire's Data Browser tool, which is a component of the GemFire Pulse Management/Monitoring tool.

The following documentation explains how to start/launch Pulse from Gfsh...

Essentially...

gfsh>start pulse

After a Locator/Manager has been started.

2) As for the Exception, GemFire currently has a bug where it attempts to load the management command classes even if the GemFire Server node is not a "Manager". This Exception is benign, but you can eliminate it by including the Spring Shell dependency on your classpath. For example, using Maven, you would declare the following dependency...

<dependency>
  <groupId>org.springframework.shell</groupId>
  <artifactId>spring-shell</artifactId>
  <version>1.0.0.RELEASE</version>
  <scope>runtime</scope>
  <exclusions>
    <exclusion>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
    </exclusion>
    <exclusion>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context-support</artifactId>
    </exclusion>
  </exclusions>
</dependency>

If you are not using Maven or Gradle, then you can do as the Exception message states and put the $GEMFIRE_HOME/lib/gfsh-dependencies on your application classpath (perhaps in your IDE).

However, if you are following the Spring Guides, then you are using either Maven or Gradle.

Hope this helps!

Cheers, John

John Blum
  • 7,381
  • 1
  • 20
  • 30
  • Thanks @John Blum , Adding that dependency worked. But my 1st problem it's not working. I mean in the above example, [link](https://spring.io/guides/gs/accessing-data-gemfire/). region name is "**hello**" so I tried to query as gfsh> query --query= "select * from /hello". also tried _gfsh>list regions_ it is saying no regions are available. And one thing i observed is spring is creating its own gemfire server. so, maybe gfsh is not knowing that server or i donno what exactly happening. thanks – Durgaprasad Kusuma Jun 08 '16 at 06:41
  • The most likely cause is that the Spring GemFire Server is not connected to the cluster you are forming in Gfsh. It is a simple matter to add an additional GemFire "`locators`" property to the example in the guide to connect it to a cluster... https://github.com/spring-guides/gs-accessing-data-gemfire/blob/master/complete/src/main/java/hello/Application.java#L22-L29. Simply add `gemfireProperties.setProperty("locators", "host[port]")`, setting the host and port appropriately based on the parameters you used in Gfsh when starting the Locator. – John Blum Jun 14 '16 at 20:47
  • I would also add that the example from the guide will fall straight through (https://github.com/spring-guides/gs-accessing-data-gemfire/blob/master/complete/src/main/java/hello/Application.java#L88-L92; along with this... https://github.com/spring-guides/gs-accessing-data-gemfire/blob/master/complete/src/main/java/hello/Application.java#L52-L86) and exit before you can inspect any 'hello' Region contents using Gfsh. This is because GemFire does nothing to block the GemFire Server/data node from shutting down (i.e. there are not non-daemon Threads in GemFire by default). So... – John Blum Jun 14 '16 at 20:48
  • You must prevent the example application (yes, a GemFire Server peer node) from exiting. Typically, if you are using GemFire's client/server topology and start a "Cache Server" (`ServerSocket`) within the GemFire Server/data node, a non-daemon Thread will block waiting for client connections, and thus prevent the server from falling through. You could also simply wait for input from standard in to signal the app to stop. Hope this helps! – John Blum Jun 14 '16 at 20:52