title: Distributed lock with Hazelcast not working
body: <p>I am trying to test my distributed lock implementation but I still haven't found a way to make it work.
  I deployed a REST service with two simple methods, like this:</p>
  
  <pre><code>@GET
  @Path("/lock")
  @Produces("text/*")
  public String lock() throws InterruptedException {
      Lock lock = distributedService.getDistributedLock("test");
      boolean result = lock.tryLock(5, TimeUnit.SECONDS);
      return result ? "locked" : "timeout";
  }
  
  @GET
  @Path("/unlock")
  @Produces("text/*")
  public String unlock() {
      Lock lock = distributedService.getDistributedLock("test");
      lock.unlock();
      return "unlocked";
  }
  </code></pre>
  
  <p>The <strong>distributedService</strong> object implements the getDistributedLock() method:</p>
  
  <pre><code>@Override
  public Lock getDistributedLock(String lockName) {
      return Hazelcast.getDefaultInstance().getLock(lockName);
  }
  </code></pre>
  
  <p>In the hazelcast.xml file, I enabled TCP-IP connection and disabled everything else:</p>
  
  <pre><code>&lt;network&gt;
  &lt;port auto-increment="true"&gt;5701&lt;/port&gt;
  &lt;join&gt;
    &lt;multicast enabled="false" /&gt;
    &lt;tcp-ip enabled="true"&gt;
      &lt;interface&gt;192.168.0.01&lt;/interface&gt;
      &lt;interface&gt;192.168.0.02&lt;/interface&gt;
    &lt;/tcp-ip&gt;
  &lt;/join&gt;
  &lt;interfaces enabled="false" /&gt;
  &lt;symmetric-encryption enabled="false" /&gt;
  &lt;asymmetric-encryption enabled="false" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>I deployed the application in the two machines, with IP adresses corresponding to the .xml file (192.168.0.01 and 192.168.0.02) and when I call the service from the browser It works for the first time (it locks and returns "locked") and everytime I call the unlock() method it returns correctly (I get the string "unlocked") but after the first time, everytime that I call the lock() method I get a timeout. It doesn't look like the unlock() method is unlocking it. </p>
  
  <p>Can someone point me the correct way to use Distributed Lock with hazelcast?</p>