title: Null Pointer Exception(not solved) and Unable to map WSResponse to Result in play 2.4 (this part solved. i guess)
body: <p>I am trying to write a simple application in Play2.4. I want to get a page and display it on my localhost which will act as a proxy. Below is my action in the controller:</p>
  
  <pre><code>public class Proxy extends Controller{
      @Inject WSClient ws;
  
      public Promise&lt;Result&gt; index(String url){
          WSRequest request = ws.url(url);
          //Promise&lt;WSResponse&gt; responsePromise = request.get();
          return Promise.promise(() -&gt; request.get())
                  .map((WSResponse wsresponse) -&gt; ok(wsresponse.getBody()).as("text/html"));
      }
  }
  </code></pre>
  
  <p>I am getting an error <code>no suitable method found for map((WSRespons[...]tml"))</code> . i am very new to Play as well as Java8. Could you please help me out here or point me in the right direction. </p>
  
  <p>Also, should we use WSResponse or just Response. The documentation is very scarce in these regards.</p>
  
  <p>I basically want the above task to be done in async. Thanks</p>
  
  <p>PS: I have been following this link <a href="https://www.playframework.com/documentation/2.4.x/JavaAsync" rel="nofollow">https://www.playframework.com/documentation/2.4.x/JavaAsync</a> and <a href="https://www.playframework.com/documentation/2.3.x/JavaAsync" rel="nofollow">https://www.playframework.com/documentation/2.3.x/JavaAsync</a>. </p>
  
  <p><strong>PPS. AS suggested in the comments by @MonCalamari i did use</strong> <code>return request.get().map((r) -&gt; ok(r.getBody()).as("text/html"));</code>
  However now i get a strange </p>
  
  <pre><code>Execution exception
  [NullPointerException: scheme]
  </code></pre>
  
  <p>at the line</p>
  
  <p><code>return request.get().map((r) -&gt; ok(r.getBody()).as("text/html"));</code></p>
  
  <p>I have tried going through the docs and other sources as well bu to no avail. Any help would be appreciated. Thanks</p>
  
  <p>Unable to get any answers...went through the stack trace but could not get anything... Below is the stack trace if someone is interested.</p>
  
  <pre><code>play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[NullPointerException: scheme]]
      at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:254) ~[play_2.11-2.4.0.jar:2.4.0]
      at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:180) ~[play_2.11-2.4.0.jar:2.4.0]
      at play.api.GlobalSettings$class.onError(GlobalSettings.scala:179) [play_2.11-2.4.0.jar:2.4.0]
      at play.api.DefaultGlobal$.onError(GlobalSettings.scala:212) [play_2.11-2.4.0.jar:2.4.0]
      at play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:94) [play_2.11-2.4.0.jar:2.4.0]
      at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$9$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:158) [play-netty-server_2.11-2.4.0.jar:2.4.0]
      at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$9$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:155) [play-netty-server_2.11-2.4.0.jar:2.4.0]
      at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36) [scala-library-2.11.6.jar:na]
      at scala.util.Failure$$anonfun$recover$1.apply(Try.scala:215) [scala-library-2.11.6.jar:na]
      at scala.util.Try$.apply(Try.scala:191) [scala-library-2.11.6.jar:na]
      at scala.util.Failure.recover(Try.scala:215) [scala-library-2.11.6.jar:na]
      at scala.concurrent.Future$$anonfun$recover$1.apply(Future.scala:324) [scala-library-2.11.6.jar:na]
      at scala.concurrent.Future$$anonfun$recover$1.apply(Future.scala:324) [scala-library-2.11.6.jar:na]
      at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) [scala-library-2.11.6.jar:na]
      at play.api.libs.iteratee.Execution$trampoline$.executeScheduled(Execution.scala:109) [play-iteratees_2.11-2.4.0.jar:2.4.0]
      at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:71) [play-iteratees_2.11-2.4.0.jar:2.4.0]
      at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:40) [scala-library-2.11.6.jar:na]
      at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:248) [scala-library-2.11.6.jar:na]
      at scala.concurrent.Promise$class.complete(Promise.scala:55) [scala-library-2.11.6.jar:na]
      at scala.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:153) [scala-library-2.11.6.jar:na]
      at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:23) [scala-library-2.11.6.jar:na]
      at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40) [akka-actor_2.11-2.3.11.jar:na]
      at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397) [akka-actor_2.11-2.3.11.jar:na]
      at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [scala-library-2.11.6.jar:na]
      at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [scala-library-2.11.6.jar:na]
      at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [scala-library-2.11.6.jar:na]
      at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [scala-library-2.11.6.jar:na]
  Caused by: java.lang.NullPointerException: scheme
      at com.ning.http.client.uri.Uri.&lt;init&gt;(Uri.java:56) ~[async-http-client-1.9.21.jar:na]
      at com.ning.http.client.uri.Uri.create(Uri.java:32) ~[async-http-client-1.9.21.jar:na]
      at com.ning.http.client.uri.Uri.create(Uri.java:25) ~[async-http-client-1.9.21.jar:na]
      at com.ning.http.client.RequestBuilderBase.setUrl(RequestBuilderBase.java:307) ~[async-http-client-1.9.21.jar:na]
      at com.ning.http.client.RequestBuilder.setUrl(RequestBuilder.java:165) ~[async-http-client-1.9.21.jar:na]
      at play.libs.ws.ning.NingWSRequest.buildRequest(NingWSRequest.java:401) ~[play-java-ws_2.11-2.4.0.jar:2.4.0]
      at play.libs.ws.ning.NingWSRequest.execute(NingWSRequest.java:394) ~[play-java-ws_2.11-2.4.0.jar:2.4.0]
      at play.libs.ws.ning.NingWSRequest.execute(NingWSRequest.java:389) ~[play-java-ws_2.11-2.4.0.jar:2.4.0]
      at play.libs.ws.ning.NingWSRequest.get(NingWSRequest.java:272) ~[play-java-ws_2.11-2.4.0.jar:2.4.0]
      at controllers.Proxy.index(Proxy.java:46) ~[classes/:2.4.0]
      at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$4$$anonfun$apply$4.apply(Routes.scala:157) ~[classes/:na]
      at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$4$$anonfun$apply$4.apply(Routes.scala:157) ~[classes/:na]
      at play.core.routing.HandlerInvokerFactory$$anon$5.resultCall(HandlerInvoker.scala:139) ~[play_2.11-2.4.0.jar:2.4.0]
      at play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$14$$anon$3$$anon$1.invocation(HandlerInvoker.scala:127) ~[play_2.11-2.4.0.jar:2.4.0]
      at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:65) ~[play_2.11-2.4.0.jar:2.4.0]
      at play.http.DefaultHttpRequestHandler$1.call(DefaultHttpRequestHandler.java:20) ~[play_2.11-2.4.0.jar:2.4.0]
      at play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:85) ~[play_2.11-2.4.0.jar:2.4.0]
      at play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:85) ~[play_2.11-2.4.0.jar:2.4.0]
      at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) [scala-library-2.11.6.jar:na]
      at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) [scala-library-2.11.6.jar:na]
      at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:40) ~[play_2.11-2.4.0.jar:2.4.0]
      at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:70) [play-iteratees_2.11-2.4.0.jar:2.4.0]
      at play.core.j.HttpExecutionContext.execute(HttpExecutionContext.scala:32) ~[play_2.11-2.4.0.jar:2.4.0]
      at scala.concurrent.impl.Future$.apply(Future.scala:31) ~[scala-library-2.11.6.jar:na]
      at scala.concurrent.Future$.apply(Future.scala:492) ~[scala-library-2.11.6.jar:na]
      at play.core.j.JavaAction.apply(JavaAction.scala:85) ~[play_2.11-2.4.0.jar:2.4.0]
      at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:105) ~[play_2.11-2.4.0.jar:2.4.0]
      at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:105) ~[play_2.11-2.4.0.jar:2.4.0]
      at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[play_2.11-2.4.0.jar:2.4.0]
      at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:104) ~[play_2.11-2.4.0.jar:2.4.0]
      at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:103) ~[play_2.11-2.4.0.jar:2.4.0]
      at scala.Option.map(Option.scala:146) ~[scala-library-2.11.6.jar:na]
      at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:103) ~[play_2.11-2.4.0.jar:2.4.0]
      at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:96) ~[play_2.11-2.4.0.jar:2.4.0]
      at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:524) ~[play-iteratees_2.11-2.4.0.jar:2.4.0]
      at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:524) ~[play-iteratees_2.11-2.4.0.jar:2.4.0]
      at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:560) ~[play-iteratees_2.11-2.4.0.jar:2.4.0]
      at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:560) ~[play-iteratees_2.11-2.4.0.jar:2.4.0]
      at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$13.apply(Iteratee.scala:536) ~[play-iteratees_2.11-2.4.0.jar:2.4.0]
      at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$13.apply(Iteratee.scala:536) ~[play-iteratees_2.11-2.4.0.jar:2.4.0]
      at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) [scala-library-2.11.6.jar:na]
      at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) [scala-library-2.11.6.jar:na]
      ... 6 common frames omitted
  </code></pre>