title: Cannot use a method returning play.mvc.WebSocket as a Handler for requests in Play?
body: <pre><code>GET    /status        controllers.Application.handleWebSocketConnection()
  </code></pre>
  
  <p>Here is the relevant source code.</p>
  
  <pre><code>public WebSocket handleWebSocketConnection() {
      return WebSocket.withActor(new F.Function&lt;ActorRef, Props&gt;() {
          @Override
          public Props apply(ActorRef actorRef) throws Throwable {
              return UserActor.props(actorRef, "");
          }
      });
  }
  </code></pre>
  
  <p>here is my build.sbt</p>
  
  <pre><code>import play.routes.compiler.InjectedRoutesGenerator
  import play.sbt.PlayScala
  
  name := "hello"
  
  version := "1.0"
  
  lazy val `dashboard` = (project in file(".")).enablePlugins(PlayScala)
  
  scalaVersion := "2.11.8"
  
  libraryDependencies ++= Seq(
    jdbc ,
    cache ,
    ws   ,
    specs2 % Test,
    "io.netty" % "netty-all" % "4.0.0"
  )
  
  unmanagedResourceDirectories in Test &lt;+=  baseDirectory ( _ /"target/web/public/test" )  
  
  resolvers ++= Seq(
    "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"
  )
  
  routesGenerator := InjectedRoutesGenerator
  
  fork in run := true
  </code></pre>
  
  <p>I am using Play version 2.4.2 and all the source code is in java 8. I get the following error. I am not sure what is going with my routes and the controller. I followed the <a href="https://www.playframework.com/documentation/2.5.x/JavaWebSockets" rel="nofollow noreferrer">link</a> here.</p>
  
  <pre><code>[error] /Users/hello/Documents/java/test_app/conf/routes:8: Cannot use a method returning play.mvc.WebSocket[?0] as a Handler for requests
  
  [error] GET    /status       controllers.Application.handleWebSocketConnection()        
  
  [error] /Users/hello/Documents/java/test_app/conf/routes:8: not enough arguments for method createInvoker: (implicit hif: play.core.routing.HandlerInvokerFactory[play.mvc.WebSocket[?0]])play.core.routing.HandlerInvoker[play.mvc.WebSocket[?0]].
  
  [error] two errors found
  
  
  [error] (compile:compile) Compilation failed
  </code></pre>
  
  <p>any ideas?</p>