Play Maven plugin doesn't seem to be generating Routes

264 views
Skip to first unread message

Nir

unread,
Nov 21, 2017, 9:15:25 PM11/21/17
to Play Framework
When I start play application using `mvn play2:start` it doesn't seem to compile any routes. But if I do `sbt run` on same project it does. 

pom.xml

    <plugin>

        <groupId>com.google.code.play2-maven-plugin</groupId>

        <artifactId>play2-maven-plugin</artifactId>

        <version>${play2.plugin.version}</version>

        <extensions>true</extensions>

        <configuration>

            <!-- if using controllers without dependency injection; default value is "injected" -->

            <routesGenerator>static</routesGenerator>

        </configuration>

    </plugin>

I am using Guice (default DI) so not sure what to put in routesGenerator. I don't see any documents either.



Here's the console output for `sbt run` after I hit localhost:9000


(Server started, use Enter to stop and go back to the console...)


[info] Compiling 13 Scala sources and 1 Java source to /Users/npatel/myworkspace/play-scala-rest-api-example/target/scala-2.11/classes ...

[error] /Users/npatel/ws/play-scala-rest-api-example/conf/routes:1:1: type HomeController is not a member of package controllers

[error] GET        /                       controllers.HomeController.index

[error] /Users/npatel/ws/play-scala-rest-api-example/conf/routes:1:1: type HomeController is not a member of package controllers

[error] GET        /                       controllers.HomeController.index

[error] /Users/npatel/ws/play-scala-rest-api-example/conf/routes:1:1: type HomeController is not a member of package controllers

[error] GET        /                       controllers.HomeController.index

[error] three errors found

[error] (root/compile:compileIncremental) Compilation failed

[error] application - 


I have removed HOmeController.index , but point is it atleast scanned all the routes and tried to compile.


WIht `mvn play2:run` I get following after I hit localhost:9000



[info] p.c.s.AkkaHttpServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

[INFO] 

[INFO] (Server started, use [Enter] to stop...)

[INFO] 

[INFO]                                                                         

[INFO] ------------------------------------------------------------------------

[INFO] Building play-scala-rest-api-example 0.0.1-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO] 

[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ play-scala-rest-api-example ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] Copying 9 resources

[INFO] Copying 5 resources

[INFO] Copying 108 resources

[INFO] 

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ play-scala-rest-api-example ---

[INFO] Nothing to compile - all classes are up to date

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 0.469 s

[INFO] Finished at: 2017-11-21T18:13:23-08:00

[INFO] Final Memory: 21M/436M

[INFO] ------------------------------------------------------------------------

[info] p.a.h.EnabledFilters - Enabled Filters (see <https://www.playframework.com/documentation/latest/Filters>):



[info] play.api.Play - Application started (Dev)

[debug] a.ErrorHandler - onClientError: statusCode = 404, uri = /, message = 



AM I missing anything here with play-maven configuration?


Grzegorz Slowikowski

unread,
Nov 22, 2017, 2:34:58 AM11/22/17
to play-framework
Hi Nir

Remove 'rootsGenerator' setting, default value will work with DI.

Regards
Grzegorz Slowikowski


What's New with Xactly

        

--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/57945408-1ae6-4ae5-a3fe-b14220490c1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nir

unread,
Nov 28, 2017, 4:21:05 PM11/28/17
to Play Framework
It didn't help.

Either Routes itself of Applicaiton itself is not getting initialize I think when I use 'mvn play2:run'

Here's the another test I did:

I removed Module config which bind the dependency of PostRepository. 

I started application using `sbt run` and as soon as I hit server I get following error which means its at least trying to init the app

No implementation for v1.post.PostRepository was bound.
  while locating v1.post.PostRepository
    for the 2nd parameter of v1.post.PostResourceHandler.<init>(PostResourceHandler.scala:44)
  while locating v1.post.PostResourceHandler
    for the 2nd parameter of v1.post.PostControllerComponents.<init>(PostActionBuilder.scala:97)
  while locating v1.post.PostControllerComponents
    for the 1st parameter of v1.post.PostController.<init>(PostController.scala:20)
  while locating v1.post.PostController
    for the 1st parameter of v1.post.PostRouter.<init>(PostRouter.scala:13)
  while locating v1.post.PostRouter
    for the 2nd parameter of router.Routes.<init>(Routes.scala:30)
  while locating router.Routes
  while locating play.api.inject.RoutesProvider
  while locating play.api.routing.Router
    for the 1st parameter of RequestHandler.<init>(RequestHandler.scala:17)
  while locating RequestHandler
  while locating play.api.http.HttpRequestHandler
    for the 6th parameter of play.api.DefaultApplication.<init>(Application.scala:236)
  at play.api.DefaultApplication.class(Application.scala:235)
  while locating play.api.DefaultApplication
  while locating play.api.Application


With `mvn play2:run` it didn't complain about it and just started but did not recognize route.

something is still missing here with play maven setup.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.

Nir

unread,
Nov 28, 2017, 6:48:50 PM11/28/17
to Play Framework



I sometimes  see above messages in UI (especially if I manually compile and then do mvn play2:run) instead of just `mvn play2:run` . 

Nir

unread,
Nov 29, 2017, 2:01:37 PM11/29/17
to Play Framework
SOLVED!

I forgot to use 'play2' as packaging in my pom.xml !

<packaging>play2</packaging>

Reply all
Reply to author
Forward
0 new messages