title: Java Maven Build: Thread.sleep doesn't work (in eclipse it does)
body: <p>I've got a strange error. My code is the following:</p>
  
  <pre><code>    LoginQueue queue = new LoginQueue(server);
      QueueTimer timer = queue.waitInQueue(this.username, this.password);
      Thread.currentThread().sleep(6000);
      while (!timer.isFinished()) {
  
          if (timer.getPosition() != 0L) {
              log("Queue Position" + server.toString() + ":"
                      + String.valueOf(timer.getPosition()), LogLevel.DEBUG);
              Thread.currentThread().sleep(3000);
          }
  </code></pre>
  
  <p>My goal is to login to the League of Legends servers using the open source riotapi: <a href="https://github.com/loldevs/riotapi/" rel="nofollow">https://github.com/loldevs/riotapi/</a></p>
  
  <p>The problem isn't LoL specific, so no problem there. When I create the <code>QueueTimer</code>, it needs some time to retrieve some data from the server, otherwise <code>timer.getPosition()</code> will throw a <code>NullPointerException</code>. That's why I wait 6 seconds before going on. In Eclipse debugging it all works fine, but after exporting it with <code>m2eclipse</code> (clean package as goals; I'm new to Maven if that matters), the compiled JAR doesn't sleep. It just goes on and then throws my <code>NullPointerException</code> because it didn't wait. Why does my code behave in Eclipse and doesn't work outside? What am I doing wrong? I've tried <code>Thread.sleep()</code> instead of <code>Thread.currentThread().sleep()</code>, doesn't work either.</p>
  
  <p>Edit:</p>
  
  <p>I changed it to:</p>
  
  <pre><code>LoginQueue queue = new LoginQueue(server);
  String authkey = queue.waitInQueueBlocking(this.username, this.password);
  </code></pre>
  
  <p>So I am using synchronous methods now. Now I get the following stacktrace: </p>
  
  <pre><code>Exception in thread "Queue Timer for LeagueAlerter" java.lang.NullPointerException
          at org.apache.cxf.jaxrs.client.AbstractClient.setupOutInterceptorChain(AbstractClient.java:840)
          at org.apache.cxf.jaxrs.client.AbstractClient.createMessage(AbstractClient.java:902)
          at org.apache.cxf.jaxrs.client.WebClient.finalizeMessage(WebClient.java:1068)
          at org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:1049)
          at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:854)
          at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:825)
          at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:393)
          at org.apache.cxf.jaxrs.client.WebClient$SyncInvokerImpl.method(WebClient.java:1582)
          at org.apache.cxf.jaxrs.client.WebClient$SyncInvokerImpl.method(WebClient.java:1577)
          at org.apache.cxf.jaxrs.client.WebClient$SyncInvokerImpl.post(WebClient.java:1517)
          at org.apache.cxf.jaxrs.client.spec.InvocationBuilderImpl.post(InvocationBuilderImpl.java:141)
          at net.boreeas.riotapi.loginqueue.LoginQueue.getAuthToken(LoginQueue.java:54)
          at net.boreeas.riotapi.loginqueue.QueueTimer.run(QueueTimer.java:89)
  </code></pre>
  
  <p>The error seems to be somewhere in the Riot API. But why does it work inside eclipse? I am too stupid to understand the API source, would be so cool if someone helped (Github is <a href="https://github.com/loldevs/riotapi/" rel="nofollow">https://github.com/loldevs/riotapi/</a> ). My pom.xml: <a href="http://pastebin.com/jik5ba8J" rel="nofollow">http://pastebin.com/jik5ba8J</a></p>