Play Modules with Routes

334 views
Skip to first unread message

Marius Soutier

unread,
Feb 1, 2017, 4:28:44 AM2/1/17
to play-fr...@googlegroups.com
Hi,

I have written a Play module that is included in the main app as a dependency. My module also provides some custom routes. This however seems to confuse the dependency injection mechanism, resulting in a `com.google.inject.ProvisionException`.

In development mode, it fails injecting the application's controllers:

ProvisionException: Unable to provision, see the following errors: 1) No implementation for services.Counter was bound. while locating services.Counter for parameter 0 at controllers.CountController.<init>(CountController.scala:17) while locating controllers.CountController for parameter 2 at router.Routes.<init>(Routes.scala:43) while locating router.Routes while locating play.api.inject.RoutesProvider

In production mode, it cannot bind the module's named actors.

When I rename the module's module.routes to routes, it works, but the module's routes override the application's routes.

I couldn't find any hint to this in the documentation, it only refers to SBT submodules, not to dependencies.


Thanks for any hint,
- Marius

Will Sargent

unread,
Feb 1, 2017, 12:43:50 PM2/1/17
to play-fr...@googlegroups.com
Hi Marius,

I assume you're referring to the note about there only being one routes file throughout the system at


The submodules are essentially dependencies here, as you have a project.dependsOn(submodule) relationship internally.  

SIRD routing is far more flexible than the generated router, so I would go that route if at all possible.  It's difficult to say more without looking at the code.

--
Will Sargent
Engineer, Lightbend, Inc.


--
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/C4E3C5E0-2A43-432B-BF78-4A22F39054ED%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Will Sargent

unread,
Feb 1, 2017, 12:44:53 PM2/1/17
to play-fr...@googlegroups.com

Will Sargent

unread,
Feb 1, 2017, 12:47:24 PM2/1/17
to play-fr...@googlegroups.com

Marius Soutier

unread,
Feb 1, 2017, 12:58:01 PM2/1/17
to play-fr...@googlegroups.com
Hi Will,

yes, I have essentially split the routes files, just as described on the page. The only difference from what's described there is that my module is in a separate project and included as a dependency.
When I just start the module as if it were a standalone Play app, everything works fine. 

Is `dependsOn()` really equivalent to an Ivy dependency? I thought there were some differences classpath-wise.

I guess SIRD routing is not an option as the users of my module will by default use injected routing.


- Marius

To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/CAJmgB600nyZgDFrVjENgygwfXZaVxFtNPa65iyJiocMHBFXzTg%40mail.gmail.com.

Marius Soutier

unread,
Feb 2, 2017, 4:00:02 PM2/2/17
to play-fr...@googlegroups.com
On 1. Feb 2017, at 18:43, Will Sargent <will.s...@lightbend.com> wrote:

To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/CAJmgB600nyZgDFrVjENgygwfXZaVxFtNPa65iyJiocMHBFXzTg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages