Q:

Play framework Javascript router not working for controller in different directory

This question is concerned with the less verbose way of giving Play's javascript router
Less Verbose way of generating Play 2's javascript router
I have two route mappings in my routes file:
GET     /attachments/:id/content      com.application.controllers.File.getOrderContent(id:String)

POST    /drive                        com.application.controllers.myapp.Drive.createDrive()

I have the non-verbose Javascript router code in a scala file:
val routeCache = {
  import routes._
  val jsRoutesClass = classOf[routes.javascript]
  val controllers = jsRoutesClass.getFields().map(_.get(null))
  controllers.flatMap { controller =>
    controller.getClass().getDeclaredMethods().map { action =>
        action.invoke(controller).asInstanceOf[play.core.Router.JavascriptReverseRoute]
    }
  }
}

def javascriptRoutes = Action { implicit request =>
    Ok(Routes.javascriptRouter("jsRoutes")(routeCache:_*)).as("text/javascript")
}

I am getting an "Uncaught TypeError: Cannot read property 'Drive' of undefined" when I am using 
jsRoutes.com.application.controllers.myapp.Drive.createDrive().ajax({...

whereas 
jsRoutes.com.application.controllers.File.getOrderContent().ajax({... works fine. 
Any thoughts on why the com.application.controllers.myapp.Drive path is not recognized by the router? I thought all the paths in the routes directory would be included in jsRoutes. 

A:

There is one one routes object and one javascript generated per package. So in your case you will have controllers.(routes|javascript) containing all the controller routes for the controllers in the package controllers and a separate controllers.myapp.(routes|javascript) for those in controllers.myapp
You can find the generated sources under target/scala-[version]/src_managed/main/controllers/routes.java and target/scala-[version]/src_managed/main/controllers/myapp/routes.java.

