Splitting routes with prefix not working in Play 2.7 (worked in 2.6)

Our project uses multiple routes files.

The conf/routes file contains something like:

/some/stuff
...

-> /api/admin       admin.Routes
-> /api/user          user.Routes

We then have conf/admin.routes and conf/user.routes files, which contain the prefixed API routes.

I’m trying to upgrade from Play 2.6 (where this setup has worked fine, as well as on earlier versions), to Play 2.7. When compiling I get the error:

[error] /usr/src/backend/conf/admin.routes:401: value concatPrefix is not a member of object play.api.routing.Router
[error] GET            /myAdminRoute                                                                        @com.my.some.controllers.MyControl.list()
[error] /usr/src/backend/conf/user.routes:140: value concatPrefix is not a member of object play.api.routing.Router
[error] GET            /myUserRoute                                                 @com.my.other.controllers.MyControl.list()

Looking at Play migration for 2.7:

I assume the issue is because of that Router withPrefix change, but I’m not sure how to interpret it in terms of what I need to update. Has anyone else had this issue with Play 2.7?

1 Like

I think the issue here was that I forgot the SBT unlock; reload; lock, but I’m not 100% sure. Starting again I get that error if I update the plugin but not lock.sbt, and it goes away if I update the lock.sbt. I’m not 100% sure if that was the issue but I think it probably was.

1 Like

I encountered this exact problem:

[error] /usr/src/backend/conf/admin.routes:401: value concatPrefix is not a member of object play.api.routing.Router
[error] GET            /some-other-route 

The root cause is that Play 2.6.x doesn’t have concatPrefix… but Play 2.7.x does.

@mcintyre1994, you probably have a dependency conflict where both Play 2.6.x and Play 2.7.x are pulled at the same time and Play 2.6.x won on the route library.

You can use https://github.com/jrudolph/sbt-dependency-graph to print the dependency tree to see how 2.6.x is still pulled in.

1 Like

That makes sense and suggests I was probably just missing an sbt reload. Thanks for the sbt-dependency-graph link, looks really useful - I’ll definitely keep that in mind next time :)