title: Hazelcast Embedded mode - How to connect to the cluster and retrieve a map from a node that is part of the cluster?
body: <p>I have a hazelcast embedded cluster of two nodes. I can access a map in the cluster if i go about using a HazelcastClient.newHazelcastClient() instance but i am not able to get the same results if i use the Hazelcast.newHazelcastInstance(). If i manipulate the map from one node, the other node works on a totally different map ; the changes arent there.</p>
  
  <p>Is it a requirement that i should use a HazelcastClient instance to connect to an embedded hazelcast cluster. It seems unnecessary to create and configure clients (hazelcast-client.xml) in embedded mode when you have the actual cluster instance object available.</p>
  
  <p>EDIT:- The discovery mechanism used is TCP. </p>
  
  <p>Setup shown below has two simple java WAR files running on two different tomcats running on the same machine. I make them discoverable via the TCP discovery mechanism as shown below. </p>
  
  <p>hazelcast.xml ( top part only )</p>
  
  <pre><code>&lt;hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.9.xsd"
             xmlns="http://www.hazelcast.com/schema/config"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
      &lt;group&gt;
          &lt;name&gt;dev&lt;/name&gt;
          &lt;password&gt;dev-pass&lt;/password&gt;
      &lt;/group&gt;
      &lt;management-center enabled="false"&gt;http://localhost:8080/mancenter&lt;/management-center&gt;
      &lt;properties&gt;
          &lt;property name="hazelcast.discovery.enabled"&gt;true&lt;/property&gt;
      &lt;/properties&gt;
      &lt;network&gt;
          &lt;port auto-increment="true" port-count="100"&gt;5701&lt;/port&gt;
          &lt;outbound-ports&gt;
              &lt;ports&gt;5700-6750&lt;/ports&gt;
          &lt;/outbound-ports&gt;
          &lt;join&gt;
              &lt;multicast enabled="false"&gt;
                  &lt;multicast-group&gt;224.2.2.3&lt;/multicast-group&gt;
                  &lt;multicast-port&gt;54327&lt;/multicast-port&gt;
              &lt;/multicast&gt;
  
  
  
              &lt;tcp-ip enabled="true"&gt;
                  &lt;member-list&gt;
                      &lt;member&gt;127.0.0.1:5701&lt;/member&gt;
                      &lt;member&gt;127.0.0.1:5702&lt;/member&gt;
                  &lt;/member-list&gt;
              &lt;/tcp-ip&gt;
  </code></pre>
  
  <p>Log Output ( from node 1 ) </p>
  
  <pre><code>STARTING UP INSTANCE...
  Apr 09, 2018 5:26:40 PM com.hazelcast.config.XmlConfigLocator
  INFO: Loading 'hazelcast.xml' from classpath.
  Apr 09, 2018 5:26:40 PM com.hazelcast.instance.AddressPicker
  INFO: [LOCAL] [dev] [3.9.3] Interfaces is disabled, trying to pick one address from TCP-IP config addresses: [127.0.0.1]
  Apr 09, 2018 5:26:40 PM com.hazelcast.instance.AddressPicker
  INFO: [LOCAL] [dev] [3.9.3] Picked [127.0.0.1]:5701, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5701], bind any local is true
  Apr 09, 2018 5:26:40 PM com.hazelcast.system
  INFO: [127.0.0.1]:5701 [dev] [3.9.3] Hazelcast 3.9.3 (20180216 - 539b124) starting at [127.0.0.1]:5701
  Apr 09, 2018 5:26:40 PM com.hazelcast.system
  INFO: [127.0.0.1]:5701 [dev] [3.9.3] Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.
  Apr 09, 2018 5:26:40 PM com.hazelcast.system
  INFO: [127.0.0.1]:5701 [dev] [3.9.3] Configured Hazelcast Serialization version: 1
  Apr 09, 2018 5:26:40 PM com.hazelcast.spi.impl.operationservice.impl.BackpressureRegulator
  INFO: [127.0.0.1]:5701 [dev] [3.9.3] Backpressure is disabled
  Apr 09, 2018 5:26:41 PM com.hazelcast.instance.Node
  INFO: [127.0.0.1]:5701 [dev] [3.9.3] Activating Discovery SPI Joiner
  Apr 09, 2018 5:26:41 PM com.hazelcast.spi.impl.operationexecutor.impl.OperationExecutorImpl
  INFO: [127.0.0.1]:5701 [dev] [3.9.3] Starting 8 partition threads and 5 generic threads (1 dedicated for priority tasks)
  Apr 09, 2018 5:26:41 PM com.hazelcast.internal.diagnostics.Diagnostics
  INFO: [127.0.0.1]:5701 [dev] [3.9.3] Diagnostics disabled. To enable add -Dhazelcast.diagnostics.enabled=true to the JVM arguments.
  Apr 09, 2018 5:26:41 PM com.hazelcast.core.LifecycleService
  INFO: [127.0.0.1]:5701 [dev] [3.9.3] [127.0.0.1]:5701 is STARTING
  09-Apr-2018 17:26:46.770 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/Users/cheni04/lac/workspace/DeveloperSetup/Servers/Tomcat/apache-tomcat-8.5.24/webapps/manager]
  09-Apr-2018 17:26:46.819 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/Users/cheni04/lac/workspace/DeveloperSetup/Servers/Tomcat/apache-tomcat-8.5.24/webapps/manager] has finished in [48] ms
  Apr 09, 2018 5:26:46 PM com.hazelcast.system
  INFO: [127.0.0.1]:5701 [dev] [3.9.3] Cluster version set to 3.9
  Apr 09, 2018 5:26:46 PM com.hazelcast.internal.cluster.ClusterService
  INFO: [127.0.0.1]:5701 [dev] [3.9.3] 
  
  Members {size:1, ver:1} [
      Member [127.0.0.1]:5701 - b011dd1b-675d-4176-ad7e-839fd813eaed this
  ]
  
  The number for this node is :1
  Apr 09, 2018 5:26:46 PM com.hazelcast.core.LifecycleService
  </code></pre>
  
  <p>Log Output ( from node 2 )</p>
  
  <pre><code>STARTING UP INSTANCE...
  Apr 09, 2018 5:27:12 PM com.hazelcast.config.XmlConfigLocator
  INFO: Loading 'hazelcast.xml' from classpath.
  Apr 09, 2018 5:27:12 PM com.hazelcast.instance.AddressPicker
  INFO: [LOCAL] [dev] [3.9.3] Interfaces is disabled, trying to pick one address from TCP-IP config addresses: [127.0.0.1]
  Apr 09, 2018 5:27:12 PM com.hazelcast.instance.AddressPicker
  INFO: [LOCAL] [dev] [3.9.3] Picked [127.0.0.1]:5702, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5702], bind any local is true
  Apr 09, 2018 5:27:12 PM com.hazelcast.system
  INFO: [127.0.0.1]:5702 [dev] [3.9.3] Hazelcast 3.9.3 (20180216 - 539b124) starting at [127.0.0.1]:5702
  Apr 09, 2018 5:27:12 PM com.hazelcast.system
  INFO: [127.0.0.1]:5702 [dev] [3.9.3] Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.
  Apr 09, 2018 5:27:12 PM com.hazelcast.system
  INFO: [127.0.0.1]:5702 [dev] [3.9.3] Configured Hazelcast Serialization version: 1
  Apr 09, 2018 5:27:13 PM com.hazelcast.spi.impl.operationservice.impl.BackpressureRegulator
  INFO: [127.0.0.1]:5702 [dev] [3.9.3] Backpressure is disabled
  Apr 09, 2018 5:27:14 PM com.hazelcast.instance.Node
  INFO: [127.0.0.1]:5702 [dev] [3.9.3] Activating Discovery SPI Joiner
  Apr 09, 2018 5:27:14 PM com.hazelcast.spi.impl.operationexecutor.impl.OperationExecutorImpl
  INFO: [127.0.0.1]:5702 [dev] [3.9.3] Starting 8 partition threads and 5 generic threads (1 dedicated for priority tasks)
  Apr 09, 2018 5:27:14 PM com.hazelcast.internal.diagnostics.Diagnostics
  INFO: [127.0.0.1]:5702 [dev] [3.9.3] Diagnostics disabled. To enable add -Dhazelcast.diagnostics.enabled=true to the JVM arguments.
  Apr 09, 2018 5:27:14 PM com.hazelcast.core.LifecycleService
  INFO: [127.0.0.1]:5702 [dev] [3.9.3] [127.0.0.1]:5702 is STARTING
  Apr 09, 2018 5:27:19 PM com.hazelcast.system
  INFO: [127.0.0.1]:5702 [dev] [3.9.3] Cluster version set to 3.9
  Apr 09, 2018 5:27:19 PM com.hazelcast.internal.cluster.ClusterService
  INFO: [127.0.0.1]:5702 [dev] [3.9.3] 
  
  Members {size:1, ver:1} [
      Member [127.0.0.1]:5702 - 4c7d74d6-0c13-4142-807b-48ab57fd7981 this
  ]
  
  Apr 09, 2018 5:27:19 PM com.hazelcast.instance.Node
  WARNING: [127.0.0.1]:5702 [dev] [3.9.3] Config seed port is 5701 and cluster size is 1. Some of the ports seem occupied!
  Apr 09, 2018 5:27:19 PM com.hazelcast.core.LifecycleService
  The number for this node is :1
  INFO: [127.0.0.1]:5702 [dev] [3.9.3] [127.0.0.1]:5702 is STARTED
  </code></pre>