问:
Issue with Jenkins and Git submodules
I am trying to get Jenkins working on a Windows PC and have found a weird issue with submodules.

I have a git repo with three submodules. After a while it seems I got Git itself working on Jenkins so a normal clone works. However the clone does not clone the submodules inside the main repo, so I checked the box to recursively update submodules.

However, when I run my job:

```<code>Started by user <User>
Building in workspace X:\Jenkins\<JobName>
- C:/Program Files/Git/bin/git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
- C:/Program Files/Git/bin/git.exe config remote.origin.url ssh://git@<server>/<repo>.git # timeout=10
Fetching upstream changes from  ssh://git@<server>/<repo>.git
- C:/Program Files/Git/bin/git.exe --version # timeout=10
using GIT_SSH to set credentials
- C:/Program Files/Git/bin/git.exe fetch --tags --progress  ssh://git@<server>/<repo>.git +refs/heads/*:refs/remotes/origin/*
- C:/Program Files/Git/bin/git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
- C:/Program Files/Git/bin/git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision b13204ee1c6717a82d1c7a17922f2a477efd119d (refs/remotes/origin/master)
Commit message: "testinggg.."
- C:/Program Files/Git/bin/git.exe config core.sparsecheckout # timeout=10
- C:/Program Files/Git/bin/git.exe checkout -f b13204ee1c6717a82d1c7a17922f2a477efd119d
- C:/Program Files/Git/bin/git.exe rev-list b13204ee1c6717a82d1c7a17922f2a477efd119d # timeout=10
- C:/Program Files/Git/bin/git.exe remote # timeout=10
- C:/Program Files/Git/bin/git.exe submodule init # timeout=10
- C:/Program Files/Git/bin/git.exe submodule sync # timeout=10
- C:/Program Files/Git/bin/git.exe config --get remote.origin.url # timeout=10
- C:/Program Files/Git/bin/git.exe submodule init # timeout=10
- C:/Program Files/Git/bin/git.exe config -f .gitmodules --get-regexp ^submodule\.(.*)\.url # timeout=10
- C:/Program Files/Git/bin/git.exe config --get submodule.top.url # timeout=10
- C:/Program Files/Git/bin/git.exe remote # timeout=10
- C:/Program Files/Git/bin/git.exe config --get remote.origin.url # timeout=10
- C:/Program Files/Git/bin/git.exe config -f .gitmodules --get submodule.top.path # timeout=10
using GIT_SSH to set credentials
- C:/Program Files/Git/bin/git.exe submodule update --init --recursive top
FATAL: Command "C:/Program Files/Git/bin/git.exe submodule update --init --recursive top" returned status code 1:
stdout:
stderr: fatal: Needed a single revision
Unable to find current revision in submodule path 'top'

hudson.plugins.git.GitException: Command "C:/Program Files/Git/bin/git.exe submodule update --init --recursive top" returned status code 1:
stdout:
stderr: fatal: Needed a single revision
Unable to find current revision in submodule path 'top'

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1903)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1622)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$7.execute(CliGitAPIImpl.java:1076)
    at hudson.plugins.git.extensions.impl.SubmoduleOption.onCheckoutCompleted(SubmoduleOption.java:102)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1182)
    at hudson.scm.SCM.checkout(SCM.java:495)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1276)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:560)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:485)
    at hudson.model.Run.execute(Run.java:1735)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:405)
Finished: FAILURE
</code>```

What does Git mean when it says:

Needed a single revision Unable to find current revision in submodule path 'top'

I have looked around and found nothing :(

I have replicated this sequence of command on a normal shell and no error appeared.

Any help will be appreciated. Thanks!

答:
Apparently 'top' is one of your submodules. The main repo that contains submodules just stores a commit ID of each of the submodules as reference to them. I interpret the error message as if there is a commit ID for 'top' in the main repo that cannot be found (does not exist?) in 'top'. I'd check this to be sure about this.

In the last project I worked with Git submodules and Jenkins we didn't use the Git plugin's Advanced sub-modules behaviours but executed all the git submodule ... commands in a Builder: Execute shell step of the Conditional BuildStep Plugin. Conditional to be able to abort the build if something goes wrong during these Git commands.

Title: Issue with Jenkins and Git submodules

Body:
I am trying to get Jenkins working on a Windows PC and have found a weird issue with submodules.

I have a git repo with three submodules. After a while it seems I got Git itself working on Jenkins so a normal clone works. However the clone does not clone the submodules inside the main repo, so I checked the box to recursively update submodules.

However, when I run my job:

Started by user <User>
Building in workspace X:\Jenkins\<JobName>
- C:/Program Files/Git/bin/git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
- C:/Program Files/Git/bin/git.exe config remote.origin.url ssh://git@<server>/<repo>.git # timeout=10
Fetching upstream changes from  ssh://git@<server>/<repo>.git
- C:/Program Files/Git/bin/git.exe --version # timeout=10
using GIT_SSH to set credentials
- C:/Program Files/Git/bin/git.exe fetch --tags --progress  ssh://git@<server>/<repo>.git +refs/heads/*:refs/remotes/origin/*
- C:/Program Files/Git/bin/git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
- C:/Program Files/Git/bin/git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision b13204ee1c6717a82d1c7a17922f2a477efd119d (refs/remotes/origin/master)
Commit message: "testinggg.."
- C:/Program Files/Git/bin/git.exe config core.sparsecheckout # timeout=10
- C:/Program Files/Git/bin/git.exe checkout -f b13204ee1c6717a82d1c7a17922f2a477efd119d
- C:/Program Files/Git/bin/git.exe rev-list b13204ee1c6717a82d1c7a17922f2a477efd119d # timeout=10
- C:/Program Files/Git/bin/git.exe remote # timeout=10
- C:/Program Files/Git/bin/git.exe submodule init # timeout=10
- C:/Program Files/Git/bin/git.exe submodule sync # timeout=10
- C:/Program Files/Git/bin/git.exe config --get remote.origin.url # timeout=10
- C:/Program Files/Git/bin/git.exe submodule init # timeout=10
- C:/Program Files/Git/bin/git.exe config -f .gitmodules --get-regexp ^submodule\.(.*)\.url # timeout=10
- C:/Program Files/Git/bin/git.exe config --get submodule.top.url # timeout=10
- C:/Program Files/Git/bin/git.exe remote # timeout=10
- C:/Program Files/Git/bin/git.exe config --get remote.origin.url # timeout=10
- C:/Program Files/Git/bin/git.exe config -f .gitmodules --get submodule.top.path # timeout=10
using GIT_SSH to set credentials
- C:/Program Files/Git/bin/git.exe submodule update --init --recursive top
FATAL: Command "C:/Program Files/Git/bin/git.exe submodule update --init --recursive top" returned status code 1:
stdout:
stderr: fatal: Needed a single revision
Unable to find current revision in submodule path 'top'

hudson.plugins.git.GitException: Command "C:/Program Files/Git/bin/git.exe submodule update --init --recursive top" returned status code 1:
stdout:
stderr: fatal: Needed a single revision
Unable to find current revision in submodule path 'top'

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1903)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1622)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$7.execute(CliGitAPIImpl.java:1076)
    at hudson.plugins.git.extensions.impl.SubmoduleOption.onCheckoutCompleted(SubmoduleOption.java:102)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1182)
    at hudson.scm.SCM.checkout(SCM.java:495)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1276)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:560)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:485)
    at hudson.model.Run.execute(Run.java:1735)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:405)
Finished: FAILURE

What does Git mean when it says:

Needed a single revision Unable to find current revision in submodule path 'top'

I have looked around and found nothing :(

I have replicated this sequence of command on a normal shell and no error appeared.

Any help will be appreciated. Thanks!


来源: stackexchange

问:
Selfmade iterator over a set in Java
In preparation for my exams I'm writing a few of the old exams that were given to us. In one of them we have to Implement an EnterpriseNode. One task is to write an iterator that iterates over the Staffmembers. I wrote the function next() but it doesn't work properly.
This is my code:

```<code>public StaffMemberIterator(HashSet<StaffMember> directSubordinates){
        if(directSubordinates == null) throw new NullPointerException("ofs");
        this.directSubordinates = directSubordinates;
    }

public StaffMember next() {
        if (!this.hasNext()){
            throw new NoSuchElementException("naf");
        }
        ArrayList<StaffMember> subList = new ArrayList<>(directSubordinates);
        StaffMember staffMember = subList.get(position);
        position++;
        return staffMember;
    }
</code>```

and this is the error:

```<code>junit.framework.AssertionFailedError: StaffMemberIterator.next() should return the correct next element if there is one available! expected:<Name: Allie, Job: J1> but was:<Name: Lilith, Job: J3>
    at StaffMemberIteratorTest.testIterator(StaffMemberIteratorTest.java:48)
</code>```

Thank you guys for any help!

答:
As Klas said in his comment, a HashSet doesn't impose any particular order. A TreeSet would impose order based on natural ordering or a defined Comparator. The order of the values in a HashSet will depend on the result of the hash function.

I'm not sure what your exam question is actually looking for, but it would make sense to implement the Iterator<E> interface given that you are implementing an iterator in Java.

Example implementation:

```<code>import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;

public class StaffIterator implements Iterator<StaffMember> {

    private final StaffMember[] staffMembers;
    private int index;

    public StaffIterator(Set<StaffMember> staffMembers) {
        this.staffMembers = staffMembers.toArray(new StaffMember[staffMembers.size()]);
        index = 0;
    }

    @Override
    public boolean hasNext() {
        return index < staffMembers.length;
    }

    @Override
    public StaffMember next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        return staffMembers[index++];
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException();
    }
}
</code>```

Note: not terribly efficent as AbstractCollection.toArray(T[] a) iterates over the Collection in order to populate the array. But it is certainly more efficient than copying a Collection into an ArrayList with each next() call.

ContentLicense: CC BY-SA 3.0

Title: Selfmade iterator over a set in Java

Body:
In preparation for my exams I'm writing a few of the old exams that were given to us. In one of them we have to Implement an EnterpriseNode. One task is to write an iterator that iterates over the Staffmembers. I wrote the function next() but it doesn't work properly.
This is my code:

public StaffMemberIterator(HashSet<StaffMember> directSubordinates){
        if(directSubordinates == null) throw new NullPointerException("ofs");
        this.directSubordinates = directSubordinates;
    }

public StaffMember next() {
        if (!this.hasNext()){
            throw new NoSuchElementException("naf");
        }
        ArrayList<StaffMember> subList = new ArrayList<>(directSubordinates);
        StaffMember staffMember = subList.get(position);
        position++;
        return staffMember;
    }

and this is the error:

junit.framework.AssertionFailedError: StaffMemberIterator.next() should return the correct next element if there is one available! expected:<Name: Allie, Job: J1> but was:<Name: Lilith, Job: J3>
    at StaffMemberIteratorTest.testIterator(StaffMemberIteratorTest.java:48)

Thank you guys for any help!

Body:
As Klas said in his comment, a HashSet doesn't impose any particular order. A TreeSet would impose order based on natural ordering or a defined Comparator. The order of the values in a HashSet will depend on the result of the hash function.

I'm not sure what your exam question is actually looking for, but it would make sense to implement the Iterator<E> interface given that you are implementing an iterator in Java.

Example implementation:

import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;

public class StaffIterator implements Iterator<StaffMember> {

    private final StaffMember[] staffMembers;
    private int index;

    public StaffIterator(Set<StaffMember> staffMembers) {
        this.staffMembers = staffMembers.toArray(new StaffMember[staffMembers.size()]);
        index = 0;
    }

    @Override
    public boolean hasNext() {
        return index < staffMembers.length;
    }

    @Override
    public StaffMember next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        return staffMembers[index++];
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException();
    }
}

Note: not terribly efficent as AbstractCollection.toArray(T[] a) iterates over the Collection in order to populate the array. But it is certainly more efficient than copying a Collection into an ArrayList with each next() call.


问:
Spring-Data-Gemfire - Unable to contact a Locator service. Operation either timed out or Locator does not exist
I want to connect to a exist locator.

Now I don't have client-server.

I started a locator,port is 40001, server1 port is 40411.

```

    gfsh>list members
     Name   | Id
    ------- | ----------------------------------------------
    test1   | 192.168.1.106(test1:1880:locator):1024
    server1 | 192.168.1.106(server1:7532):1025

```

Configuration is:

```

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:gfe-data="http://www.springframework.org/schema/data/gemfire"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:gfe="http://www.springframework.org/schema/gemfire"
      xmlns:repository="http://www.springframework.org/schema/data/repository"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:util="http://www.springframework.org/schema/util"
      xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
      http://www.springframework.org/schema/data/gemfire http://www.springframework.org/schema/data/gemfire/spring-data-gemfire.xsd
      http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/data/repository/spring-repository.xsd
      http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

        <util:properties id="gemfireProperties">
            <prop key="locators">localhost[40001]
            <prop key="mcast-port">0
        </util:properties>

        <gfe:cache properties-ref="gemfireProperties"/>

        <gfe:cache-server port="40411" />

        <bean id="portGenerator" class="com.demo.server.ServerPortGenerator" />

        <gfe:replicated-region id="Person"/>

    </beans>

```

Error is :

```

    [info 2017/07/04 23:48:12.546 CST  tid=0x1] Defaulting license-working-dir to current working directory "C:\Users\IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\demo".

    [info 2017/07/04 23:48:12.547 CST  tid=0x1] Licensing required 2 milliseconds.

    [info 2017/07/04 23:48:12.923 CST  tid=0x1] GemFire P2P Listener started on  tcp:///192.168.1.106:53073

    [info 2017/07/04 23:48:13.094 CST  tid=0x20] unable to connect to locator  localhost(null):40001

    2017-07-04 23:48:16.200  WARN 10904 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireServer': Cannot resolve reference to bean 'gemfireCache' while setting bean property 'cache'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.  Configured list of locators is "[localhost(null):40001]".
    2017-07-04 23:48:16.200  WARN 10904 --- [           main] o.s.b.f.support.DisposableBeanAdapter    : Invocation of destroy method failed on bean with name 'gemfireCache': com.gemstone.gemfire.cache.CacheClosedException: A cache has not yet been created.
    2017-07-04 23:48:16.219 ERROR 10904 --- [           main] o.s.boot.SpringApplication               : Application startup failed

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireServer': Cannot resolve reference to bean 'gemfireCache' while setting bean property 'cache'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.  Configured list of locators is "[localhost(null):40001]".
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1531) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:742) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at com.demo.server.ServerApplication.main(ServerApplication.java:32) [classes/:na]
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.  Configured list of locators is "[localhost(null):40001]".
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1634) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        ... 16 common frames omitted
    Caused by: com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.  Configured list of locators is "[localhost(null):40001]".
        at com.gemstone.org.jgroups.protocols.TCPGOSSIP.sendGetMembersRequest(TCPGOSSIP.java:222) ~[gemfire-8.2.4.jar:na]
        at com.gemstone.org.jgroups.protocols.PingSender.run(PingSender.java:85) ~[gemfire-8.2.4.jar:na]
        at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_111]

```

Oh my god, I have no idea for this problem.

Anyone who can help me ?

I just want to build a client-server system.

But now I even couldn't to set-up the server.

Update on July.09 - 2017

Hello John, I tried your example, but I still met error.

First, I use gfsh to start a locator.

```

    C:\Users\IBM_ADMIN>gfsh
        _________________________     __
       / _____/ ______/ ______/ /____/ /
      / /  __/ /___  /_____  / _____  /
     / /__/ / ____/  _____/ / /    / /
    /______/_/      /______/_/    /_/    9.0.4

    Monitor and Manage Pivotal GemFire
    gfsh>start locator --name=GemFireLocator --log-level=config
    Starting a Geode Locator in C:\Users\IBM_ADMIN\GemFireLocator...
    ......
    Locator in C:\Users\IBM_ADMIN\GemFireLocator on ADMINIB-CI3Q48M[10334] as GemFireLocator is currently online.
    Process ID: 7256
    Uptime: 8 seconds
    GemFire Version: 9.0.4
    Java Version: 1.8.0_101
    Log File: C:\Users\IBM_ADMIN\GemFireLocator\GemFireLocator.log
    JVM Arguments: -Dgemfire.enable-cluster-configuration=true -Dgemfire.load-cluster-configuration-from-dir=false -Dgemfire
    .log-level=config -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterva
    l=9223372036854775806
    Class-Path: C:\Program Files\Java\pivotal-gemfire-9.0.4\lib\geode-core-9.0.4.jar;C:\Program Files\Java\pivotal-gemfire-9
    .0.4\lib\geode-dependencies.jar

    Successfully connected to: JMX Manager [host=ADMINIB-CI3Q48M, port=1099]

    gfsh>list members
         Name      | Id
    -------------- | -------------------------------------------------------
    GemFireLocator | 192.168.1.106(GemFireLocator:7256:locator):1024

    gfsh>describe member --name=GemFireLocator
    Name        : GemFireLocator
    Id          : 192.168.1.106(GemFireLocator:7256:locator):1024
    Host        : ADMINIB-CI3Q48M
    Regions     :
    PID         : 7256
    Groups      :
    Used Heap   : 90M
    Max Heap    : 1755M
    Working Dir : C:\Users\IBM_ADMIN\GemFireLocator
    Log file    : C:\Users\IBM_ADMIN\GemFireLocator\GemFireLocator.log
    Locators    : 192.168.1.106[10334]

```

And then as you mentioned in the spring-boot-gemfire-server-example, I tried to run $gradlew bootRun.

But the error shows:
Caused by: java.net.BindException: Address already in use: JVM_Bind

```
    [info 2017/07/09 14:57:24.270 CST  tid=0x1] Defaulting license-working-dir to current working directory "C:\Users
    IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\spring-boot-gemfire-server-example".

    [info 2017/07/09 14:57:24.273 CST  tid=0x1] Licensing required 4 milliseconds.

    [info 2017/07/09 14:57:24.324 CST  tid=0x1] Starting peer location for Distribution Locator on localhost/127.0.0.
    [10334]

    [info 2017/07/09 14:57:24.333 CST  tid=0x1] Starting Distribution Locator on localhost/127.0.0.1[10334]

    [info 2017/07/09 14:57:24.347 CST  tid=0x1] Distribution Locator on localhost/127.0.0.1[10334]  is stopped

    [main] WARN org.springframework.context.annotation.AnnotationConfigApplicationContext - Exception encountered during co
    text initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Err
    r creating bean with name 'gemfireCacheServer' defined in org.example.SpringBootGemFireServer: Unsatisfied dependency e
    pressed through method 'gemfireCacheServer' parameter 0; nested exception is org.springframework.beans.factory.BeanCrea
    ionException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exce
    tion is com.gemstone.gemfire.GemFireIOException: Problem starting a locator service
    [main] WARN org.springframework.beans.factory.support.DisposableBeanAdapter - Invocation of destroy method failed on be
    n with name 'gemfireCache': com.gemstone.gemfire.cache.CacheClosedException: A cache has not yet been created.
    [main] INFO org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer -

    Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enable
    .
    [main] ERROR org.springframework.boot.SpringApplication - Application startup failed
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gemfireCacheServer' de
    ined in org.example.SpringBootGemFireServer: Unsatisfied dependency expressed through method 'gemfireCacheServer' param
    ter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemf
    reCache': FactoryBean threw exception on object creation; nested exception is com.gemstone.gemfire.GemFireIOException:
    roblem starting a locator service
            at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:7
    9)
            at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResol
    er.java:467)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(A
    stractAutowireCapableBeanFactory.java:1128)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAuto
    ireCapableBeanFactory.java:1022)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCa
    ableBeanFactory.java:512)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapa
    leBeanFactory.java:482)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
            at org.springframework.beans.factory.suefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.ja
    a: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(DefaultListabl
    BeanFactory.java:735)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractAppli
    ationContext.java:866)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
            at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
            at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
            at org.example.SpringBootGemFireServer.main(SpringBootGemFireServer.java:52)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': Facto
    yBean threw exception on object creation; nested exception is com.gemstone.gemfire.GemFireIOException: Problem starting
    a locator service
            at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanR
    gistrySupport.java:175)
            at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanReg
    strySupport.java:103)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.j
    va:1606)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:317)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
         rg.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBean
    actory.java:1131)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFa
    tory.java:1059)
            at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.j
    va:835)
            at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:7
    1)
            ... 18 more
    Caused by: com.gemstone.gemfire.GemFireIOException: Problem starting a locator service
            at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.startInitLocator(InternalDistributedSyst
    m.java:847)
            at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.initialize(InternalDistributedSystem.jav
    :606)
            at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.newInstance(InternalDistributedSystem.ja
    a:281)
            at com.gemstone.gemfire.distributed.DistributedSystem.connect(DistributedSystem.java:1651)
            at com.gemstone.gemfire.cache.CacheFactory.create(CacheFactory.java:227)
            at org.springframework.data.gemfire.CacheFactoryBean.createCache(CacheFactoryBean.java:356)
            at org.springframework.data.gemfire.CacheFactoryBean.resolveCache(CacheFactoryBean.java:250)
            at org.springframework.data.gemfire.CacheFactoryBean.init(CacheFactoryBean.java:191)
            at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:178)
            at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:88)
            at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanR
    gistrySupport.java:168)
            ... 27 more
    Caused by: java.net.BindException: Failed to create server socket on  localhost/127.0.0.1[10,334]
            at com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:829)
            at com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:789)
            at com.gemstone.org.jgroups.stack.tcpserver.TcpServer.startServerThread(TcpServer.java:179)
            at com.gemstone.org.jgroups.stack.tcpserver.TcpServer.start(TcpServer.java:168)
            at com.gemstone.gemfire.distributed.internal.InternalLocator.startTcpServer(InternalLocator.java:629)
            at com.gemstone.gemfire.distributed.internal.InternalLocator.startPeerLocation(InternalLocator.java:698)
            at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.startInitLocator(InternalDistributedSyst
    m.java:832)
            ... 37 more
    Caused by: java.net.BindException: Address already in use: JVM_Bind
            at java.net.DualStackPlainSocketImpl.bind0(Native Method)
            at java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106)
            at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
            at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190)
            at java.net.ServerSocket.bind(ServerSocket.java:375)
            at com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:826)
            ... 43 more
    :bootRun FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':bootRun'.
    > Process 'command 'C:\Program Files\Java\jdk1.8.0_101\bin\java.exe'' finished with non-zero exit value 1

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

    Total time: 14.9 secs
```

And then, I used gfsh to stopped the locator.

I tried to run your example directly ( without start a locator first ).

Unbelievable, it succeed.

It seems like that your example is to start a new Gemfire locator and a server, not connect to a exist locator.

```

    [info 2017/07/09 15:19:16.930 CST  tid=0x1] Defaulting license-working-dir to current working directory "C:\Users\
    IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\spring-boot-gemfire-server-example".

    [info 2017/07/09 15:19:16.935 CST  tid=0x1] Licensing required 7 milliseconds.

    [info 2017/07/09 15:19:17.000 CST  tid=0x1] Starting peer location for Distribution Locator on localhost/127.0.0.1
    [10334]

    [info 2017/07/09 15:19:17.016 CST  tid=0x1] Starting Distribution Locator on localhost/127.0.0.1[10334]

    [info 2017/07/09 15:19:18.376 CST  tid=0x1] GemFire P2P Listener started on  tcp:///192.168.1.106:45643

    [info 2017/07/09 15:19:18.624 CST  tid=0x22] locator localhost(null):10334 member address is ADMINIB-CI3
    Q48M(SpringBootGemFireServer):37651

    [info 2017/07/09 15:19:25.674 CST  tid=0x25] locator localhost(null):10334 member address is ADMINIB-CI3
    Q48M(SpringBootGemFireServer):37651

    [info 2017/07/09 15:19:30.686 CST  tid=0x1] Membership: lead member is now ADMINIB-CI3Q48M(SpringBootGemFireServer
    ):37651

    [info 2017/07/09 15:19:30.701 CST  tid=0x1] This member, ADMINIB-CI3Q48M(SpringBootGemFireServer):37651, is becomi
    ng group coordinator.

    [info 2017/07/09 15:19:30.710 CST  tid=0x1] Entered into membership with ID ADMINIB-CI3Q48M(SpringBootGemFireServe
    r):37651.

    [info 2017/07/09 15:19:30.712 CST  tid=0x1] Starting DistributionManager ADMINIB-CI3Q48M(SpringBootGemFireServer):37651.  (took 12629/ ms)

    [info 2017/07/09 15:19:30.715 CST  tid=0x1] Initial (membershipManager) view =  [ADMINIB-CI3Q48M(SpringBootGemFire
    Server):37651{lead}]

    [info 2017/07/09 15:19:30.715 CST  tid=0x1] Admitting member :37651>.
     Now there are 1 non-admin member(s).

    [info 2017/07/09 15:19:30.716 CST  tid=0x1] ADMINIB-CI3Q48M(SpringBootGemFireServer):37651 is the elder and th
    e only member.

    [info 2017/07/09 15:19:31.081 CST  tid=0x1] Did not hear back from any other system. I am the first one.

    [info 2017/07/09 15:19:31.086 CST  tid=0x1] Starting server location for Distribution Locator on localhost/127.0.0
    .1[10334]

    [info 2017/07/09 15:19:31.358 CST  tid=0x1] Initializing region _monitoringRegion_192.168.1.10637651

    [info 2017/07/09 15:19:31.364 CST  tid=0x1] Initialization of region _monitoringRegion_192.168.1.10637651 comp
    leted

    [info 2017/07/09 15:19:32.857 CST  tid=0x1] Initializing region PdxTypes

    [info 2017/07/09 15:19:32.857 CST  tid=0x1] Initialization of region PdxTypes completed

    [main] INFO org.springframework.data.gemfire.CacheFactoryBean - Connected to Distributed System [SpringBootGemFireServer
    ] as Member [ADMINIB-CI3Q48M(SpringBootGemFireServer):37651]in Group(s) [[]] with Role(s) [[]] on Host [ADMINIB-CI3Q
    48M] having PID [0].
    [main] INFO org.springframework.data.gemfire.CacheFactoryBean - Created new GemFire v.8.2.0 Cache [SpringBootGemFireServ
    er].
    [info 2017/07/09 15:19:32.935 CST  tid=0x1] Initializing region __PR

    [info 2017/07/09 15:19:32.935 CST  tid=0x1] Initialization of region __PR completed

    [info 2017/07/09 15:19:32.986 CST  tid=0x1] Partitioned Region /Factorials is born with prId=1 ident:#Factorials

    [main] INFO org.springframework.data.gemfire.PartitionedRegionFactoryBean - Created new Cache Region [Factorials].
    [main] INFO org.springframework.jmx.export.annotation.AnnotationMBeanExporter - Registering beans for JMX exposure on st
    artup
    [main] INFO org.springframework.context.support.DefaultLifecycleProcessor - Starting beans in phase 2147483647
    [info 2017/07/09 15:19:33.379 CST  tid=0x1] Bridge server connection listener bound to address localhost/127.0.0.1
    :40404 with backlog 1,000.

    [info 2017/07/09 15:19:33.396 CST  tid=0x1] ClientHealthMonitorThread maximum allowed time between pings: 15,000

    [info 2017/07/09 15:19:33.425 CST  tid=0x1] CacheServer Configuration:   port=40404 max-connections=800 max-thread
    s=0 notify-by-subscription=true socket-buffer-size=32768 maximum-time-between-pings=15000 maximum-message-count=230000 m
    essage-time-to-live=180 eviction-policy=none capacity=1 overflow directory=. groups=[] loadProbe=ConnectionCountProbe lo
    adPollInterval=5000 tcpNoDelay=true

    [main] INFO org.example.SpringBootGemFireServer - Started SpringBootGemFireServer in 20.399 seconds (JVM running for 20.
    823)
    [info 2017/07/09 15:21:15.585 CST  tid=0x3e] (tid=62 msgId=0) Executing list member
    s

    [info 2017/07/09 15:22:26.546 CST  tid=0x3e] (tid=62 msgId=1) Executing describe me
    mber --name GemFireLocator

    > Building 80% > :bootRun

```

And I can use gfsh to connect to the locator what your example code created.

```

    gfsh>
    gfsh>stop locator --name GemFireLocator
    Stopping Locator running in C:\Users\IBM_ADMIN\GemFireLocator on ADMINIB-CI3Q48M[10334] as GemFireLocator...
    Process ID: 7256
    Log File: C:\Users\IBM_ADMIN\GemFireLocator\GemFireLocator.log
    ....

    No longer connected to ADMINIB-CI3Q48M[1099].
    gfsh>gfsh>list members
    "list members" is not available. Reason: Requires connection.
    gfsh>connect to loaclhost[10334]
    Connecting to Locator at [host=localhost, port=10334] ..
    Connecting to Manager at [host=ADMINIB-CI3Q48M, port=1199] ..
    Successfully connected to: [host=ADMINIB-CI3Q48M, port=1199]

    gfsh>list members
    Member Count : 1
    Coordinator  : SpringBootGemFireServer (ADMINIB-CI3Q48M(SpringBootGemFireServer):37651)

             Name           | Id
    ----------------------- | --------------------------------------------------
    SpringBootGemFireServer | ADMINIB-CI3Q48M(SpringBootGemFireServer):37651
    gfsh>describe member --name=SpringBootGemFireServer
    Name        : SpringBootGemFireServer
    Id          : ADMINIB-CI3Q48M(SpringBootGemFireServer):37651
    Host        : ADMINIB-CI3Q48M
    Regions     : Factorials

    PID         : 0
    Groups      :
    Used Heap   : 117M
    Max Heap    : 1755M
    Working Dir : C:\Users\IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\spring-boot-gemfire-server-example
    Log file    : C:\Users\IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\spring-boot-gemfire-server-example
    Locators    : localhost[10334]

    Cache Server Information
    Server Bind              : localhost
    Server Port              : 40404
    Running                  : true
    Client Connections       : 0

    gfsh>list regions
    List of regions
    ---------------
    Factorials

    gfsh>describe region --name=/Factorials
    ..........................................................
    Name            : Factorials
    Data Policy     : partition
    Hosting Members : SpringBootGemFireServer

    Non-Default Attributes Shared By Hosting Members

     Type  | Name | Value
    ------ | ---- | -----
    Region | size | 0

```

Could you plese help to check it ?

答:
Well, the Stack Trace is pretty revealing in this case.

Essentially, the Spring container was unable to create an instance of a GemFire "peer" cache (which is based on the <gfe:cache> element in your Spring XML config) because GemFire was unable to find the Locator you started from Gfsh...

```<code>Caused by: com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.  Configured list of locators is "[localhost(null):40001]".
        at com.gemstone.org.jgroups.protocols.TCPGOSSIP.sendGetMembersRequest(TCPGOSSIP.java:222) ~[gemfire-8.2.4.jar:na]
        at com.gemstone.org.jgroups.protocols.PingSender.run(PingSender.java:85) ~[gemfire-8.2.4.jar:na]
        at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_111]
</code>```

Hence...

c.g.g.GemFireConfigException: Unable to contact a Locator service. Operation either timed out or Locator does not exist.

It goes on to state that...

Configured list of locators is "[localhost(null):40001]".

The locators property in your gemfireProperties bean definition (which defines the "GemFire properties") is what a pending GemFire peer looking to join a cluster uses to find the GemFire Locator (and by extension, the cluster to join).  Indeed, 1 or more Locator endpoints (e.g. host1[port1],host2[port2],...,hostN[portN]) defines the cluster to which the pending peer member will join.

Outside of your malformed XML for the gemfireProperties bean definition in your Spring XML config, the value of the locators property appears to be correct.  You have a "Locator" running locally, listening on port 40001, at least according to your statements.  That is NOT apparent from the list members command, though.

So...

Fist, I assume "test1" is your Locator?

And, you started your Locator using... gfsh> start locator --name=tests1 --port=40001 ...  (I also suggest turning up the log level with --log-level=config)

Finally, I assume "server1" is indeed a "GemFire Server"?

If "'test1" is indeed your Locator, then you can get the runtime information for the Locator usingstatus locator`, for instance...

```<code>gfsh>status locator --name=test1
Locator in /Users/jblum/pivdev/lab/test1 on 10.99.199.10[40001] as test1 is currently online.
Process ID: 89632
Uptime: 1 minute 15 seconds
GemFire Version: 9.0.4
Java Version: 1.8.0_121
Log File: /Users/jblum/pivdev/lab/test1/test1.log
JVM Arguments: -Dgemfire.enable-cluster-configuration=true -Dgemfire.load-cluster-configuration-from-dir=false -Dgemfire.log-level=config -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806
Class-Path: /Users/jblum/Downloads/Pivotal/GemStone/Products/PivotalGemFire/pivotal-gemfire-9.0.4/lib/geode-core-9.0.4.jar:/Users/jblum/Downloads/Pivotal/GemStone/Products/PivotalGemFire/pivotal-gemfire-9.0.4/lib/geode-dependencies.jar

Cluster configuration service is up and running.
</code>```

Now, I have a project, complete with documentation/instructions, you can use to connect a GemFire CacheServer, peer cache application configured with Spring (Data GemFire) and bootstrapped with Spring Boot, available here.

My "tests1" Locator is already running, as shown above with the status locator --name=test1 Gfsh command.  If I list members before starting my Spring Boot GemFire peer cache, CacheServer application, you see this...

```<code>gfsh>list members
Name  | Id
----- | ----------------------------------------------
test1 | 10.99.199.10(test1:89632:locator)<ec><v0>:1024
</code>```

Then, when I start my embedded server, you see this...

```<code>gfsh>list members
         Name           | Id
----------------------- | --------------------------------------------------------
test1                   | 10.99.199.10(test1:89632:locator)<ec><v0>:1024
SpringBootGemFireServer | 10.99.199.10(SpringBootGemFireServer:89790)<ec><v1>:1025
</code>```

NOTE: I ran the server from inside my IDE (IntelliJ IDEA).  Of course, it would work from the command-line too.

NOTE: Since the Locator is NOT running on the default port (i.e. 10334), it is running on 40001, you need to set the custom, application spring.gemfire.locators JVM System property before running the server, to "localhost[40001]".  This property translates into GemFire's locators property here and here.

Because list members shows both GemFire processes (Locator + Server), you know that the Server has joined the cluster based on the Locator.

Again, feel free to refer to my example.

Hope this helps!

-John

Body:
I want to connect to a exist locator.

Now I don't have client-server.

I started a locator,port is 40001, server1 port is 40411.

    gfsh>list members
     Name   | Id
    ------- | ----------------------------------------------
    test1   | 192.168.1.106(test1:1880:locator):1024
    server1 | 192.168.1.106(server1:7532):1025

Configuration is:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:gfe-data="http://www.springframework.org/schema/data/gemfire"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:gfe="http://www.springframework.org/schema/gemfire"
      xmlns:repository="http://www.springframework.org/schema/data/repository"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:util="http://www.springframework.org/schema/util"
      xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
      http://www.springframework.org/schema/data/gemfire http://www.springframework.org/schema/data/gemfire/spring-data-gemfire.xsd
      http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/data/repository/spring-repository.xsd
      http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

        <util:properties id="gemfireProperties">
            <prop key="locators">localhost[40001]
            <prop key="mcast-port">0
        </util:properties>

        <gfe:cache properties-ref="gemfireProperties"/>

        <gfe:cache-server port="40411" />

        <bean id="portGenerator" class="com.demo.server.ServerPortGenerator" />

        <gfe:replicated-region id="Person"/>

    </beans>

Error is :

    [info 2017/07/04 23:48:12.546 CST  tid=0x1] Defaulting license-working-dir to current working directory "C:\Users\IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\demo".

    [info 2017/07/04 23:48:12.547 CST  tid=0x1] Licensing required 2 milliseconds.

    [info 2017/07/04 23:48:12.923 CST  tid=0x1] GemFire P2P Listener started on  tcp:///192.168.1.106:53073

    [info 2017/07/04 23:48:13.094 CST  tid=0x20] unable to connect to locator  localhost(null):40001

    2017-07-04 23:48:16.200  WARN 10904 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireServer': Cannot resolve reference to bean 'gemfireCache' while setting bean property 'cache'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.  Configured list of locators is "[localhost(null):40001]".
    2017-07-04 23:48:16.200  WARN 10904 --- [           main] o.s.b.f.support.DisposableBeanAdapter    : Invocation of destroy method failed on bean with name 'gemfireCache': com.gemstone.gemfire.cache.CacheClosedException: A cache has not yet been created.
    2017-07-04 23:48:16.219 ERROR 10904 --- [           main] o.s.boot.SpringApplication               : Application startup failed

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireServer': Cannot resolve reference to bean 'gemfireCache' while setting bean property 'cache'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.  Configured list of locators is "[localhost(null):40001]".
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1531) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:742) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at com.demo.server.ServerApplication.main(ServerApplication.java:32) [classes/:na]
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.  Configured list of locators is "[localhost(null):40001]".
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1634) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        ... 16 common frames omitted
    Caused by: com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.  Configured list of locators is "[localhost(null):40001]".
        at com.gemstone.org.jgroups.protocols.TCPGOSSIP.sendGetMembersRequest(TCPGOSSIP.java:222) ~[gemfire-8.2.4.jar:na]
        at com.gemstone.org.jgroups.protocols.PingSender.run(PingSender.java:85) ~[gemfire-8.2.4.jar:na]
        at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_111]

Oh my god, I have no idea for this problem.

Anyone who can help me ?

I just want to build a client-server system.

But now I even couldn't to set-up the server.

Update on July.09 - 2017

Hello John, I tried your example, but I still met error.

First, I use gfsh to start a locator.

    C:\Users\IBM_ADMIN>gfsh
        _________________________     __
       / _____/ ______/ ______/ /____/ /
      / /  __/ /___  /_____  / _____  /
     / /__/ / ____/  _____/ / /    / /
    /______/_/      /______/_/    /_/    9.0.4

    Monitor and Manage Pivotal GemFire
    gfsh>start locator --name=GemFireLocator --log-level=config
    Starting a Geode Locator in C:\Users\IBM_ADMIN\GemFireLocator...
    ......
    Locator in C:\Users\IBM_ADMIN\GemFireLocator on ADMINIB-CI3Q48M[10334] as GemFireLocator is currently online.
    Process ID: 7256
    Uptime: 8 seconds
    GemFire Version: 9.0.4
    Java Version: 1.8.0_101
    Log File: C:\Users\IBM_ADMIN\GemFireLocator\GemFireLocator.log
    JVM Arguments: -Dgemfire.enable-cluster-configuration=true -Dgemfire.load-cluster-configuration-from-dir=false -Dgemfire
    .log-level=config -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterva
    l=9223372036854775806
    Class-Path: C:\Program Files\Java\pivotal-gemfire-9.0.4\lib\geode-core-9.0.4.jar;C:\Program Files\Java\pivotal-gemfire-9
    .0.4\lib\geode-dependencies.jar

    Successfully connected to: JMX Manager [host=ADMINIB-CI3Q48M, port=1099]

    gfsh>list members
         Name      | Id
    -------------- | -------------------------------------------------------
    GemFireLocator | 192.168.1.106(GemFireLocator:7256:locator):1024

    gfsh>describe member --name=GemFireLocator
    Name        : GemFireLocator
    Id          : 192.168.1.106(GemFireLocator:7256:locator):1024
    Host        : ADMINIB-CI3Q48M
    Regions     :
    PID         : 7256
    Groups      :
    Used Heap   : 90M
    Max Heap    : 1755M
    Working Dir : C:\Users\IBM_ADMIN\GemFireLocator
    Log file    : C:\Users\IBM_ADMIN\GemFireLocator\GemFireLocator.log
    Locators    : 192.168.1.106[10334]

And then as you mentioned in the spring-boot-gemfire-server-example, I tried to run $gradlew bootRun.

But the error shows:
Caused by: java.net.BindException: Address already in use: JVM_Bind

    [info 2017/07/09 14:57:24.270 CST  tid=0x1] Defaulting license-working-dir to current working directory "C:\Users
    IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\spring-boot-gemfire-server-example".

    [info 2017/07/09 14:57:24.273 CST  tid=0x1] Licensing required 4 milliseconds.

    [info 2017/07/09 14:57:24.324 CST  tid=0x1] Starting peer location for Distribution Locator on localhost/127.0.0.
    [10334]

    [info 2017/07/09 14:57:24.333 CST  tid=0x1] Starting Distribution Locator on localhost/127.0.0.1[10334]

    [info 2017/07/09 14:57:24.347 CST  tid=0x1] Distribution Locator on localhost/127.0.0.1[10334]  is stopped

    [main] WARN org.springframework.context.annotation.AnnotationConfigApplicationContext - Exception encountered during co
    text initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Err
    r creating bean with name 'gemfireCacheServer' defined in org.example.SpringBootGemFireServer: Unsatisfied dependency e
    pressed through method 'gemfireCacheServer' parameter 0; nested exception is org.springframework.beans.factory.BeanCrea
    ionException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exce
    tion is com.gemstone.gemfire.GemFireIOException: Problem starting a locator service
    [main] WARN org.springframework.beans.factory.support.DisposableBeanAdapter - Invocation of destroy method failed on be
    n with name 'gemfireCache': com.gemstone.gemfire.cache.CacheClosedException: A cache has not yet been created.
    [main] INFO org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer -

    Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enable
    .
    [main] ERROR org.springframework.boot.SpringApplication - Application startup failed
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gemfireCacheServer' de
    ined in org.example.SpringBootGemFireServer: Unsatisfied dependency expressed through method 'gemfireCacheServer' param
    ter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemf
    reCache': FactoryBean threw exception on object creation; nested exception is com.gemstone.gemfire.GemFireIOException:
    roblem starting a locator service
            at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:7
    9)
            at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResol
    er.java:467)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(A
    stractAutowireCapableBeanFactory.java:1128)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAuto
    ireCapableBeanFactory.java:1022)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCa
    ableBeanFactory.java:512)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapa
    leBeanFactory.java:482)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
            at org.springframework.beans.factory.suefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.ja
    a: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(DefaultListabl
    BeanFactory.java:735)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractAppli
    ationContext.java:866)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
            at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
            at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
            at org.example.SpringBootGemFireServer.main(SpringBootGemFireServer.java:52)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': Facto
    yBean threw exception on object creation; nested exception is com.gemstone.gemfire.GemFireIOException: Problem starting
    a locator service
            at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanR
    gistrySupport.java:175)
            at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanReg
    strySupport.java:103)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.j
    va:1606)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:317)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
         rg.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBean
    actory.java:1131)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFa
    tory.java:1059)
            at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.j
    va:835)
            at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:7
    1)
            ... 18 more
    Caused by: com.gemstone.gemfire.GemFireIOException: Problem starting a locator service
            at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.startInitLocator(InternalDistributedSyst
    m.java:847)
            at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.initialize(InternalDistributedSystem.jav
    :606)
            at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.newInstance(InternalDistributedSystem.ja
    a:281)
            at com.gemstone.gemfire.distributed.DistributedSystem.connect(DistributedSystem.java:1651)
            at com.gemstone.gemfire.cache.CacheFactory.create(CacheFactory.java:227)
            at org.springframework.data.gemfire.CacheFactoryBean.createCache(CacheFactoryBean.java:356)
            at org.springframework.data.gemfire.CacheFactoryBean.resolveCache(CacheFactoryBean.java:250)
            at org.springframework.data.gemfire.CacheFactoryBean.init(CacheFactoryBean.java:191)
            at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:178)
            at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:88)
            at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanR
    gistrySupport.java:168)
            ... 27 more
    Caused by: java.net.BindException: Failed to create server socket on  localhost/127.0.0.1[10,334]
            at com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:829)
            at com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:789)
            at com.gemstone.org.jgroups.stack.tcpserver.TcpServer.startServerThread(TcpServer.java:179)
            at com.gemstone.org.jgroups.stack.tcpserver.TcpServer.start(TcpServer.java:168)
            at com.gemstone.gemfire.distributed.internal.InternalLocator.startTcpServer(InternalLocator.java:629)
            at com.gemstone.gemfire.distributed.internal.InternalLocator.startPeerLocation(InternalLocator.java:698)
            at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.startInitLocator(InternalDistributedSyst
    m.java:832)
            ... 37 more
    Caused by: java.net.BindException: Address already in use: JVM_Bind
            at java.net.DualStackPlainSocketImpl.bind0(Native Method)
            at java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106)
            at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
            at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190)
            at java.net.ServerSocket.bind(ServerSocket.java:375)
            at com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:826)
            ... 43 more
    :bootRun FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':bootRun'.
    > Process 'command 'C:\Program Files\Java\jdk1.8.0_101\bin\java.exe'' finished with non-zero exit value 1

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

    Total time: 14.9 secs

And then, I used gfsh to stopped the locator.

I tried to run your example directly ( without start a locator first ).

Unbelievable, it succeed.

It seems like that your example is to start a new Gemfire locator and a server, not connect to a exist locator.

    [info 2017/07/09 15:19:16.930 CST  tid=0x1] Defaulting license-working-dir to current working directory "C:\Users\
    IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\spring-boot-gemfire-server-example".

    [info 2017/07/09 15:19:16.935 CST  tid=0x1] Licensing required 7 milliseconds.

    [info 2017/07/09 15:19:17.000 CST  tid=0x1] Starting peer location for Distribution Locator on localhost/127.0.0.1
    [10334]

    [info 2017/07/09 15:19:17.016 CST  tid=0x1] Starting Distribution Locator on localhost/127.0.0.1[10334]

    [info 2017/07/09 15:19:18.376 CST  tid=0x1] GemFire P2P Listener started on  tcp:///192.168.1.106:45643

    [info 2017/07/09 15:19:18.624 CST  tid=0x22] locator localhost(null):10334 member address is ADMINIB-CI3
    Q48M(SpringBootGemFireServer):37651

    [info 2017/07/09 15:19:25.674 CST  tid=0x25] locator localhost(null):10334 member address is ADMINIB-CI3
    Q48M(SpringBootGemFireServer):37651

    [info 2017/07/09 15:19:30.686 CST  tid=0x1] Membership: lead member is now ADMINIB-CI3Q48M(SpringBootGemFireServer
    ):37651

    [info 2017/07/09 15:19:30.701 CST  tid=0x1] This member, ADMINIB-CI3Q48M(SpringBootGemFireServer):37651, is becomi
    ng group coordinator.

    [info 2017/07/09 15:19:30.710 CST  tid=0x1] Entered into membership with ID ADMINIB-CI3Q48M(SpringBootGemFireServe
    r):37651.

    [info 2017/07/09 15:19:30.712 CST  tid=0x1] Starting DistributionManager ADMINIB-CI3Q48M(SpringBootGemFireServer):37651.  (took 12629/ ms)

    [info 2017/07/09 15:19:30.715 CST  tid=0x1] Initial (membershipManager) view =  [ADMINIB-CI3Q48M(SpringBootGemFire
    Server):37651{lead}]

    [info 2017/07/09 15:19:30.715 CST  tid=0x1] Admitting member :37651>.
     Now there are 1 non-admin member(s).

    [info 2017/07/09 15:19:30.716 CST  tid=0x1] ADMINIB-CI3Q48M(SpringBootGemFireServer):37651 is the elder and th
    e only member.

    [info 2017/07/09 15:19:31.081 CST  tid=0x1] Did not hear back from any other system. I am the first one.

    [info 2017/07/09 15:19:31.086 CST  tid=0x1] Starting server location for Distribution Locator on localhost/127.0.0
    .1[10334]

    [info 2017/07/09 15:19:31.358 CST  tid=0x1] Initializing region _monitoringRegion_192.168.1.10637651

    [info 2017/07/09 15:19:31.364 CST  tid=0x1] Initialization of region _monitoringRegion_192.168.1.10637651 comp
    leted

    [info 2017/07/09 15:19:32.857 CST  tid=0x1] Initializing region PdxTypes

    [info 2017/07/09 15:19:32.857 CST  tid=0x1] Initialization of region PdxTypes completed

    [main] INFO org.springframework.data.gemfire.CacheFactoryBean - Connected to Distributed System [SpringBootGemFireServer
    ] as Member [ADMINIB-CI3Q48M(SpringBootGemFireServer):37651]in Group(s) [[]] with Role(s) [[]] on Host [ADMINIB-CI3Q
    48M] having PID [0].
    [main] INFO org.springframework.data.gemfire.CacheFactoryBean - Created new GemFire v.8.2.0 Cache [SpringBootGemFireServ
    er].
    [info 2017/07/09 15:19:32.935 CST  tid=0x1] Initializing region __PR

    [info 2017/07/09 15:19:32.935 CST  tid=0x1] Initialization of region __PR completed

    [info 2017/07/09 15:19:32.986 CST  tid=0x1] Partitioned Region /Factorials is born with prId=1 ident:#Factorials

    [main] INFO org.springframework.data.gemfire.PartitionedRegionFactoryBean - Created new Cache Region [Factorials].
    [main] INFO org.springframework.jmx.export.annotation.AnnotationMBeanExporter - Registering beans for JMX exposure on st
    artup
    [main] INFO org.springframework.context.support.DefaultLifecycleProcessor - Starting beans in phase 2147483647
    [info 2017/07/09 15:19:33.379 CST  tid=0x1] Bridge server connection listener bound to address localhost/127.0.0.1
    :40404 with backlog 1,000.

    [info 2017/07/09 15:19:33.396 CST  tid=0x1] ClientHealthMonitorThread maximum allowed time between pings: 15,000

    [info 2017/07/09 15:19:33.425 CST  tid=0x1] CacheServer Configuration:   port=40404 max-connections=800 max-thread
    s=0 notify-by-subscription=true socket-buffer-size=32768 maximum-time-between-pings=15000 maximum-message-count=230000 m
    essage-time-to-live=180 eviction-policy=none capacity=1 overflow directory=. groups=[] loadProbe=ConnectionCountProbe lo
    adPollInterval=5000 tcpNoDelay=true

    [main] INFO org.example.SpringBootGemFireServer - Started SpringBootGemFireServer in 20.399 seconds (JVM running for 20.
    823)
    [info 2017/07/09 15:21:15.585 CST  tid=0x3e] (tid=62 msgId=0) Executing list member
    s

    [info 2017/07/09 15:22:26.546 CST  tid=0x3e] (tid=62 msgId=1) Executing describe me
    mber --name GemFireLocator

    > Building 80% > :bootRun

And I can use gfsh to connect to the locator what your example code created.

    gfsh>
    gfsh>stop locator --name GemFireLocator
    Stopping Locator running in C:\Users\IBM_ADMIN\GemFireLocator on ADMINIB-CI3Q48M[10334] as GemFireLocator...
    Process ID: 7256
    Log File: C:\Users\IBM_ADMIN\GemFireLocator\GemFireLocator.log
    ....

    No longer connected to ADMINIB-CI3Q48M[1099].
    gfsh>gfsh>list members
    "list members" is not available. Reason: Requires connection.
    gfsh>connect to loaclhost[10334]
    Connecting to Locator at [host=localhost, port=10334] ..
    Connecting to Manager at [host=ADMINIB-CI3Q48M, port=1199] ..
    Successfully connected to: [host=ADMINIB-CI3Q48M, port=1199]

    gfsh>list members
    Member Count : 1
    Coordinator  : SpringBootGemFireServer (ADMINIB-CI3Q48M(SpringBootGemFireServer):37651)

             Name           | Id
    ----------------------- | --------------------------------------------------
    SpringBootGemFireServer | ADMINIB-CI3Q48M(SpringBootGemFireServer):37651
    gfsh>describe member --name=SpringBootGemFireServer
    Name        : SpringBootGemFireServer
    Id          : ADMINIB-CI3Q48M(SpringBootGemFireServer):37651
    Host        : ADMINIB-CI3Q48M
    Regions     : Factorials

    PID         : 0
    Groups      :
    Used Heap   : 117M
    Max Heap    : 1755M
    Working Dir : C:\Users\IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\spring-boot-gemfire-server-example
    Log file    : C:\Users\IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\spring-boot-gemfire-server-example
    Locators    : localhost[10334]

    Cache Server Information
    Server Bind              : localhost
    Server Port              : 40404
    Running                  : true
    Client Connections       : 0

    gfsh>list regions
    List of regions
    ---------------
    Factorials

    gfsh>describe region --name=/Factorials
    ..........................................................
    Name            : Factorials
    Data Policy     : partition
    Hosting Members : SpringBootGemFireServer

    Non-Default Attributes Shared By Hosting Members

     Type  | Name | Value
    ------ | ---- | -----
    Region | size | 0

Could you plese help to check it ?

Body:
Well, the Stack Trace is pretty revealing in this case.

Essentially, the Spring container was unable to create an instance of a GemFire "peer" cache (which is based on the <gfe:cache> element in your Spring XML config) because GemFire was unable to find the Locator you started from Gfsh...

Caused by: com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.  Configured list of locators is "[localhost(null):40001]".
        at com.gemstone.org.jgroups.protocols.TCPGOSSIP.sendGetMembersRequest(TCPGOSSIP.java:222) ~[gemfire-8.2.4.jar:na]
        at com.gemstone.org.jgroups.protocols.PingSender.run(PingSender.java:85) ~[gemfire-8.2.4.jar:na]
        at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_111]

Hence...

c.g.g.GemFireConfigException: Unable to contact a Locator service. Operation either timed out or Locator does not exist.

It goes on to state that...

Configured list of locators is "[localhost(null):40001]".

The locators property in your gemfireProperties bean definition (which defines the "GemFire properties") is what a pending GemFire peer looking to join a cluster uses to find the GemFire Locator (and by extension, the cluster to join).  Indeed, 1 or more Locator endpoints (e.g. host1[port1],host2[port2],...,hostN[portN]) defines the cluster to which the pending peer member will join.

Outside of your malformed XML for the gemfireProperties bean definition in your Spring XML config, the value of the locators property appears to be correct.  You have a "Locator" running locally, listening on port 40001, at least according to your statements.  That is NOT apparent from the list members command, though.

So...

Fist, I assume "test1" is your Locator?

And, you started your Locator using... gfsh> start locator --name=tests1 --port=40001 ...  (I also suggest turning up the log level with --log-level=config)

Finally, I assume "server1" is indeed a "GemFire Server"?

If "'test1" is indeed your Locator, then you can get the runtime information for the Locator usingstatus locator`, for instance...

gfsh>status locator --name=test1
Locator in /Users/jblum/pivdev/lab/test1 on 10.99.199.10[40001] as test1 is currently online.
Process ID: 89632
Uptime: 1 minute 15 seconds
GemFire Version: 9.0.4
Java Version: 1.8.0_121
Log File: /Users/jblum/pivdev/lab/test1/test1.log
JVM Arguments: -Dgemfire.enable-cluster-configuration=true -Dgemfire.load-cluster-configuration-from-dir=false -Dgemfire.log-level=config -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806
Class-Path: /Users/jblum/Downloads/Pivotal/GemStone/Products/PivotalGemFire/pivotal-gemfire-9.0.4/lib/geode-core-9.0.4.jar:/Users/jblum/Downloads/Pivotal/GemStone/Products/PivotalGemFire/pivotal-gemfire-9.0.4/lib/geode-dependencies.jar

Cluster configuration service is up and running.

Now, I have a project, complete with documentation/instructions, you can use to connect a GemFire CacheServer, peer cache application configured with Spring (Data GemFire) and bootstrapped with Spring Boot, available here.

My "tests1" Locator is already running, as shown above with the status locator --name=test1 Gfsh command.  If I list members before starting my Spring Boot GemFire peer cache, CacheServer application, you see this...

gfsh>list members
Name  | Id
----- | ----------------------------------------------
test1 | 10.99.199.10(test1:89632:locator)<ec><v0>:1024

Then, when I start my embedded server, you see this...

gfsh>list members
         Name           | Id
----------------------- | --------------------------------------------------------
test1                   | 10.99.199.10(test1:89632:locator)<ec><v0>:1024
SpringBootGemFireServer | 10.99.199.10(SpringBootGemFireServer:89790)<ec><v1>:1025

NOTE: I ran the server from inside my IDE (IntelliJ IDEA).  Of course, it would work from the command-line too.

NOTE: Since the Locator is NOT running on the default port (i.e. 10334), it is running on 40001, you need to set the custom, application spring.gemfire.locators JVM System property before running the server, to "localhost[40001]".  This property translates into GemFire's locators property here and here.

Because list members shows both GemFire processes (Locator + Server), you know that the Server has joined the cluster based on the Locator.

Again, feel free to refer to my example.

Hope this helps!

-John


问:
Determine when sent user to home if logged in correctly
Im developing a mobile app and i need to determine when user is logged in correctly to send into Home page, else user only see Login page.

My user.ts (Provider)

```<code>import { Injectable } from '@angular/core';
import { Http, URLSearchParams } from '@angular/http';
import { api } from '../../config/url.api';
import { Observable } from "rxjs/Rx"
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';

import { AlertController, Platform } from 'ionic-angular';

// Plugin storage
import { Storage } from '@ionic/storage';

@Injectable()
export class User {

  user_id: string;
  user_firstname: string;

  constructor( public http: Http, private alertCtrl: AlertController, private platform: Platform, private storage: Storage ) {

    // Cargamos el storage con datos almacenados
    this.load_storage();

  }

  login_user( US_EMAIL: string, US_PASSWD: string ){

    let data = new URLSearchParams();

    data.append( "Usuario_app[US_EMAIL]", US_EMAIL );
    data.append( "Usuario_app[US_PASSWD]", US_PASSWD );

    let url = "/api" + "/usuario_app/acceso"; // Cambiame en los builds

    return this.http.post( url, data )
    .map( resp => {
      let data_resp = resp.json();
      console.log( data_resp );

      if( data_resp.ResponseError ) {

        // Si el JSON retorna error al enviar datos a la API, mostramos una alerta
        this.alertCtrl.create({
          title: "Error",
          message: data_resp.ResponseError,
          buttons: ["Aceptar"]
        }).present();

        console.log('Hubo un error al iniciar sesión');

      } else {
        // El JSON retornó sin errores
        this.user_id = data_resp.USUARIO.US_ID;
        this.user_firstname = data_resp.USUARIO.US_NOMBRE;

        // Almacenamos la ID del usuario
        this.save_storage();

        console.log('Sesión inciada con éxito, se guardó en el storage');
      }
    })
  }

  remove_user(){

    this.user_id = null;

    // guardar storage
    this.save_storage();

  }

  private save_storage(){

    if( this.platform.is("cordova") ){

      // En el dispositivo
      this.storage.set('user_id', this.user_id );

    } else {

      // En el Computador
      if( this.user_id ){
        localStorage.setItem("user_id",  this.user_id  );
        console.log('Guardé el user_id: ' + this.user_id);
      } else {
        localStorage.removeItem("user_id");

        console.log('Borré de tu local el usuario');
      }
    }
  }

  load_storage(){

    let promise = new Promise( ( resolve, reject ) => {

      if( this.platform.is("cordova") ){

        // dispositivo
        this.storage.ready()
        .then( () => {
          this.storage.get("user_id")
          .then( user_id => {
            if( user_id ) {
              this.user_id = user_id;
            }
            resolve();
          })
        })
      } else {
        // computadora
        if( localStorage.getItem("user_id") ){
          //Existe items en el localstorage
          this.user_id = localStorage.getItem("user_id");
          console.log('Cargué el user_id: ' + this.user_id);
        }
        resolve();
      }
    });

    return promise;
  }
}
</code>```

Okay, so, when user is in Login Page, have two options

Login Sucessfully -> Go Home

Login Incorrect -> Try Again

I try some snippet but user goes to Home when the login is incorrect too

My login.ts (Page)

```<code>import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, LoadingController } from 'ionic-angular';
// import * as CryptoJS from 'crypto-js';
// import CryptoJS from 'crypto-js';
import * as sha1 from 'js-sha1';

import { User } from "../../providers/user/user";

import { HomePage } from '../../pages/home/home';

@IonicPage()
@Component({
  selector: 'page-login',
  templateUrl: 'login.html',
})
export class LoginPage {

  US_EMAIL: string = "";
  US_PASSWD: string = "";

  constructor(public navCtrl: NavController, public navParams: NavParams, private user: User, private loadingCtrl: LoadingController ) {
    // console.log('Mensaje encriptado ' + sha1('Hola soy un mensaje encriptado'));
  }

  login(){

    // Envía la password encriptada en SHA1
    this.user.login_user( this.US_EMAIL, sha1(this.US_PASSWD) )
    .subscribe( () => {

      // Acá tendría que discriminar si enviar o no al usuario al home siempre cuando haya validado su inicio de sesión

      // console.log( 'Encripté tu contraseña: ' + sha1( this.US_PASSWD ));

    })
  }
}
</code>```

In advance, thank you!

答: This type of functionality is often handled using a route guard. There is an authorization example here: https://angular.io/guide/router#milestone-5-route-guards</p>

Body:
Im developing a mobile app and i need to determine when user is logged in correctly to send into Home page, else user only see Login page.

My user.ts (Provider)

import { Injectable } from '@angular/core';
import { Http, URLSearchParams } from '@angular/http';
import { api } from '../../config/url.api';
import { Observable } from "rxjs/Rx"
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';

import { AlertController, Platform } from 'ionic-angular';

// Plugin storage
import { Storage } from '@ionic/storage';

@Injectable()
export class User {

  user_id: string;
  user_firstname: string;

  constructor( public http: Http, private alertCtrl: AlertController, private platform: Platform, private storage: Storage ) {

    // Cargamos el storage con datos almacenados
    this.load_storage();

  }

  login_user( US_EMAIL: string, US_PASSWD: string ){

    let data = new URLSearchParams();

    data.append( "Usuario_app[US_EMAIL]", US_EMAIL );
    data.append( "Usuario_app[US_PASSWD]", US_PASSWD );

    let url = "/api" + "/usuario_app/acceso"; // Cambiame en los builds

    return this.http.post( url, data )
    .map( resp => {
      let data_resp = resp.json();
      console.log( data_resp );

      if( data_resp.ResponseError ) {

        // Si el JSON retorna error al enviar datos a la API, mostramos una alerta
        this.alertCtrl.create({
          title: "Error",
          message: data_resp.ResponseError,
          buttons: ["Aceptar"]
        }).present();

        console.log('Hubo un error al iniciar sesión');

      } else {
        // El JSON retornó sin errores
        this.user_id = data_resp.USUARIO.US_ID;
        this.user_firstname = data_resp.USUARIO.US_NOMBRE;

        // Almacenamos la ID del usuario
        this.save_storage();

        console.log('Sesión inciada con éxito, se guardó en el storage');
      }
    })
  }

  remove_user(){

    this.user_id = null;

    // guardar storage
    this.save_storage();

  }

  private save_storage(){

    if( this.platform.is("cordova") ){

      // En el dispositivo
      this.storage.set('user_id', this.user_id );

    } else {

      // En el Computador
      if( this.user_id ){
        localStorage.setItem("user_id",  this.user_id  );
        console.log('Guardé el user_id: ' + this.user_id);
      } else {
        localStorage.removeItem("user_id");

        console.log('Borré de tu local el usuario');
      }
    }
  }

  load_storage(){

    let promise = new Promise( ( resolve, reject ) => {

      if( this.platform.is("cordova") ){

        // dispositivo
        this.storage.ready()
        .then( () => {
          this.storage.get("user_id")
          .then( user_id => {
            if( user_id ) {
              this.user_id = user_id;
            }
            resolve();
          })
        })
      } else {
        // computadora
        if( localStorage.getItem("user_id") ){
          //Existe items en el localstorage
          this.user_id = localStorage.getItem("user_id");
          console.log('Cargué el user_id: ' + this.user_id);
        }
        resolve();
      }
    });

    return promise;
  }
}

Okay, so, when user is in Login Page, have two options

Login Sucessfully -> Go Home

Login Incorrect -> Try Again

I try some snippet but user goes to Home when the login is incorrect too

My login.ts (Page)

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, LoadingController } from 'ionic-angular';
// import * as CryptoJS from 'crypto-js';
// import CryptoJS from 'crypto-js';
import * as sha1 from 'js-sha1';

import { User } from "../../providers/user/user";

import { HomePage } from '../../pages/home/home';

@IonicPage()
@Component({
  selector: 'page-login',
  templateUrl: 'login.html',
})
export class LoginPage {

  US_EMAIL: string = "";
  US_PASSWD: string = "";

  constructor(public navCtrl: NavController, public navParams: NavParams, private user: User, private loadingCtrl: LoadingController ) {
    // console.log('Mensaje encriptado ' + sha1('Hola soy un mensaje encriptado'));
  }

  login(){

    // Envía la password encriptada en SHA1
    this.user.login_user( this.US_EMAIL, sha1(this.US_PASSWD) )
    .subscribe( () => {

      // Acá tendría que discriminar si enviar o no al usuario al home siempre cuando haya validado su inicio de sesión

      // console.log( 'Encripté tu contraseña: ' + sha1( this.US_PASSWD ));

    })
  }
}

In advance, thank you!


问:
Sequelize Eeager Loading Error - Can't figure out include
I'm working with sequelize on an Angular and Nodejs built application. I've built a User model that hasMany notfications as a sender and hasMany notifications as a receiver. The notifications model also belongsTo User as a sender and belongsTo user as receiver. My issue is when I try to implement a GET http request on the notifications, I am receiving a Sequelize Eager Loading Error. I've commented out the include statement, as well as the notifications attribute on user, and the GET request works. I just don't understand what is causing the error.

Here are my models.

"use strict";

```<code>module.exports = function(sequelize, DataTypes) {
  var Notification = sequelize.define("Notification", {
    startAddress: DataTypes.STRING,
    endAddress: DataTypes.STRING,
    tripDate: DataTypes.DATE,
    tripHour: DataTypes.INTEGER,
    numberOfPassengers: DataTypes.INTEGER,
    price: {
      type: DataTypes.INTEGER,
      defaultValue: -1
    }
  });
  Notification.associate = function(models) {
    Notification.belongsTo(models.User, {
      as: "sender",
      onDelete: "CASCADE",
      foreignKey: "senderId"
    });
    Notification.belongsTo(models.User, {
      as: "receiver",
      onDelete: "CASCADE",
      foreignKey: "receiverId"
    });
  };
  return Notification;
};

"use strict";

module.exports = function(sequelize, DataTypes) {
  var User = sequelize.define("User", {
    email: DataTypes.STRING,
    password: DataTypes.STRING,
    profileImgUrl: DataTypes.STRING,
    fName: DataTypes.STRING,
    lName: DataTypes.STRING,
    yearOfBirth: DataTypes.INTEGER,
    gender: DataTypes.STRING,
    ratings: {
      type: DataTypes.ARRAY(DataTypes.INTEGER),
      defaultValue: [5]
    },
    createdAt: {
      type: DataTypes.DATE,
      defaultValue: sequelize.literal('NOW()')
    },
    updatedAt: {
      type: DataTypes.DATE,
      defaultValue: sequelize.literal('NOW()')
    }
  });
  User.associate = function(models) {
    User.hasMany(models.RideRequest, {
      onDelete: "CASCADE",
      foreignKey: "riderId"
    });
    User.hasMany(models.DriveRequest, {
      onDelete: "CASCADE",
      foreignKey: "driverId"
    });
    User.hasMany(models.Notification, {
      as: 'sender',
      onDelete: "CASCADE",
      foreignKey: "senderId"
    });
    User.hasMany(models.Notification, {
      as: 'receiver',
      onDelete: "CASCADE",
      foreignKey: "receiverId"
    });
  };
  return User;
};
</code>```

And here is my notifications controller, which holds the logic for the notifications routes.

```<code>list: function list(req,res) {
    var decoded = jwt.decode(req.query.token);
    return model.User.findOne({
      where: {id: decoded.user.id},
      include: [{
        model: model.Notification
      }]
    }).then(function (user) {
        let ratingAv;
        for (let rating of user.ratings) {
          ratingAv = (user.ratings.length/(rating += rating)*10);
        }
        console.log(ratingAv + ' RATINGSSSS');
        let resObj = Object.assign({}, {
          id: user.id,
          profileImgUrl: user.profileImgUrl,
          fName: user.fName,
          lName: user.lName,
          yearOfBirth: user.yearOfBirth,
          gender: user.gender,
          ratings: ratingAv,
          notifications: user.Notifications.map(function(notification) {
            return Object.assign({}, {
              id: notification.id,
              startAddress: notification.startAddress,
              endAddress: notification.endAddress,
              tripDate: notification.tripDate,
              tripHour: notification.tripHour,
              numberOfPassengers: notification.numberOfPassengers,
              price: notification.price,
              senderId: notification.senderId,
              receiverId: notification.receiverId
            });
          })
        });
      return res.status(201).json({
        message: 'Notifications retrieved successfully',
        obj: resObj
      });
    }).catch(function (err) {
      return res.status(400).json({
        title: 'There was an error retrieving notifications',
        error: err
      });
    });
  },
</code>```

If I could even get a better error somehow, I'd be able to figure it out. The error is very generalized and doesn't help me understand what may be misspelled, misplaced or etc. Can anyone figure out what the issue is?

答: I was missing the as: parameter in my include option. If you are using multiple instances of the same model on the same model (as User, User both on Notification), then you need to use Aliases to identify them with the as: option on include: . Good luck!</p>

Body:
I'm working with sequelize on an Angular and Nodejs built application. I've built a User model that hasMany notfications as a sender and hasMany notifications as a receiver. The notifications model also belongsTo User as a sender and belongsTo user as receiver. My issue is when I try to implement a GET http request on the notifications, I am receiving a Sequelize Eager Loading Error. I've commented out the include statement, as well as the notifications attribute on user, and the GET request works. I just don't understand what is causing the error.

Here are my models.

"use strict";

module.exports = function(sequelize, DataTypes) {
  var Notification = sequelize.define("Notification", {
    startAddress: DataTypes.STRING,
    endAddress: DataTypes.STRING,
    tripDate: DataTypes.DATE,
    tripHour: DataTypes.INTEGER,
    numberOfPassengers: DataTypes.INTEGER,
    price: {
      type: DataTypes.INTEGER,
      defaultValue: -1
    }
  });
  Notification.associate = function(models) {
    Notification.belongsTo(models.User, {
      as: "sender",
      onDelete: "CASCADE",
      foreignKey: "senderId"
    });
    Notification.belongsTo(models.User, {
      as: "receiver",
      onDelete: "CASCADE",
      foreignKey: "receiverId"
    });
  };
  return Notification;
};

"use strict";

module.exports = function(sequelize, DataTypes) {
  var User = sequelize.define("User", {
    email: DataTypes.STRING,
    password: DataTypes.STRING,
    profileImgUrl: DataTypes.STRING,
    fName: DataTypes.STRING,
    lName: DataTypes.STRING,
    yearOfBirth: DataTypes.INTEGER,
    gender: DataTypes.STRING,
    ratings: {
      type: DataTypes.ARRAY(DataTypes.INTEGER),
      defaultValue: [5]
    },
    createdAt: {
      type: DataTypes.DATE,
      defaultValue: sequelize.literal('NOW()')
    },
    updatedAt: {
      type: DataTypes.DATE,
      defaultValue: sequelize.literal('NOW()')
    }
  });
  User.associate = function(models) {
    User.hasMany(models.RideRequest, {
      onDelete: "CASCADE",
      foreignKey: "riderId"
    });
    User.hasMany(models.DriveRequest, {
      onDelete: "CASCADE",
      foreignKey: "driverId"
    });
    User.hasMany(models.Notification, {
      as: 'sender',
      onDelete: "CASCADE",
      foreignKey: "senderId"
    });
    User.hasMany(models.Notification, {
      as: 'receiver',
      onDelete: "CASCADE",
      foreignKey: "receiverId"
    });
  };
  return User;
};

And here is my notifications controller, which holds the logic for the notifications routes.

list: function list(req,res) {
    var decoded = jwt.decode(req.query.token);
    return model.User.findOne({
      where: {id: decoded.user.id},
      include: [{
        model: model.Notification
      }]
    }).then(function (user) {
        let ratingAv;
        for (let rating of user.ratings) {
          ratingAv = (user.ratings.length/(rating += rating)*10);
        }
        console.log(ratingAv + ' RATINGSSSS');
        let resObj = Object.assign({}, {
          id: user.id,
          profileImgUrl: user.profileImgUrl,
          fName: user.fName,
          lName: user.lName,
          yearOfBirth: user.yearOfBirth,
          gender: user.gender,
          ratings: ratingAv,
          notifications: user.Notifications.map(function(notification) {
            return Object.assign({}, {
              id: notification.id,
              startAddress: notification.startAddress,
              endAddress: notification.endAddress,
              tripDate: notification.tripDate,
              tripHour: notification.tripHour,
              numberOfPassengers: notification.numberOfPassengers,
              price: notification.price,
              senderId: notification.senderId,
              receiverId: notification.receiverId
            });
          })
        });
      return res.status(201).json({
        message: 'Notifications retrieved successfully',
        obj: resObj
      });
    }).catch(function (err) {
      return res.status(400).json({
        title: 'There was an error retrieving notifications',
        error: err
      });
    });
  },

If I could even get a better error somehow, I'd be able to figure it out. The error is very generalized and doesn't help me understand what may be misspelled, misplaced or etc. Can anyone figure out what the issue is?