[2.3.0-scala] Compile error: routes is already defined as object/class routes

2,367 views
Skip to first unread message

Grant Gavares

unread,
Jun 5, 2014, 11:34:08 AM6/5/14
to play-fr...@googlegroups.com
Just upgraded from Play 2.3-RC1 --> 2.3.0 and scala 2.10.3 --> 2.11.1

Compilation of the project now fails with error:

[error] conf/routes: routes is already defined as object routes
[error] conf/routes: routes is already defined as class routes
[error] conf/routes: routes is already defined as object routes
[error] conf/routes: routes is already defined as class routes
[error] conf/routes: routes is already defined as object routes
[error] conf/routes: routes is already defined as class routes
[error] conf/routes:34: ReverseAssets is already defined as class ReverseAssets
[error] GET     /assets/*file               controllers.Assets.at(path="/public", file)
[error] conf/routes:6: ReverseAccountsService is already defined as class ReverseAccountsService
[error] GET     /healthcheck                controllers.AccountsService.healthCheck
[error] conf/routes:29: ReverseMetricsController is already defined as class ReverseMetricsController
[error] GET     /metrics                    metrics.MetricsController.showMetrics
...
...
...

This is a multi-project sbt build where there is one subproject under the 'api' directory that only compiles an client to be used for talking to the service remotely and doesn't have any dependencies on Play or any play libs.

The main/top-level project depends on the api subproject.

There is only a single routes files defined in the project.



Grant Gavares

unread,
Jun 5, 2014, 2:46:14 PM6/5/14
to play-fr...@googlegroups.com
More detail:

First, I moved two of my controllers from within their own packages (metrics and migrations) under the controller package. This reduced the number of errors but the build is still failing with the same overall errors.

grepping for one of the failing ReverseXXXControllers, I can see that ReverseMetricsController is defined 3 times in the same file target/src_managed/main/routes_reverseRouting.scala each enclosed within an package definition:

Line 194:
package controllers {

...

// @LINE: 29

class ReverseMetricsController {
    

// @LINE:29
def showMetrics(): Call = {
   import ReverseRouteContext.empty
   Call("GET", _prefix + { _defaultPrefix } + "metrics")
}
                        
    
}
                          
}
                  




Line 455:
package controllers.javascript {

...

// @LINE:29
class ReverseMetricsController {
    

// @LINE:29
def showMetrics : JavascriptReverseRoute = JavascriptReverseRoute(
   "controllers.MetricsController.showMetrics",
   """
      function() {
      return _wA({method:"GET", url:"""" + _prefix + { _defaultPrefix } + """" + "metrics"})
      }
   """
)
                        
    
}
              
}



Line 631:
package controllers.ref {

...

// @LINE:29
class ReverseMetricsController {
    

// @LINE:29
def showMetrics(): play.api.mvc.HandlerRef[_] = new play.api.mvc.HandlerRef(
   controllers.MetricsController.showMetrics(), HandlerDef(this.getClass.getClassLoader, "", "controllers.MetricsController", "showMetrics", Seq(), "GET", """""", _prefix + """metrics""")
)
                      
    
}
                          
}
Message has been deleted

Grant Gavares

unread,
Jun 5, 2014, 6:38:29 PM6/5/14
to play-fr...@googlegroups.com
Appears to be an issue related to scala 2.11.1 as downgrading to scala 2.10.4 fixes the problem.

hell...@gmail.com

unread,
Sep 14, 2014, 12:32:04 PM9/14/14
to play-fr...@googlegroups.com
Looks like, this is known scalac bug:
https://issues.scala-lang.org/browse/SI-4549
Still unfixed and unvoted.

The error is confusing, because there are no syntax errors in routes-generated sources. But it does not compile.

Our project have same compile errors, ~400 LOCs in conf/routes, and issue 100% reproduceable on scala 2.11 and never occurs on 2.10.x. So, migration on scala-2.11 impossible. Hope, play-2.4 will support compiling against scala-2.10...

четверг, 5 июня 2014 г., 19:34:08 UTC+4 пользователь Grant Gavares написал:

Daniel Bimschas

unread,
May 20, 2016, 3:48:29 AM5/20/16
to play-framework
Hi there,

I ran into the same problem. Did you guys find a workaround?

Konstantin Nikiforov

unread,
May 20, 2016, 3:56:10 AM5/20/16
to play-fr...@googlegroups.com
Hi.

As for me, issue silently gone away in end-2014 or 2015 after upgrading
to play 2.4.x & scala-2.11.n, AFAIR.

Never seen it again.

Matthias Brandt

unread,
May 20, 2016, 4:56:54 AM5/20/16
to play-framework
Hi,


Am Freitag, 20. Mai 2016 09:56:10 UTC+2 schrieb Konstantin Nikiforov:
As for me, issue silently gone away in end-2014 or 2015 after upgrading
to play 2.4.x & scala-2.11.n, AFAIR.

Never seen it again.

That's nice to hear. Unfortunately, this doesn't work in our project :-(

Matthias Brandt

unread,
May 24, 2016, 10:58:53 AM5/24/16
to play-framework
I was wrong, it works.
Due to my frustration I cloned our repository to a new location to test it there. But while trying to update play, I didn't realized that my sbt shell was still in the old project :-/
Reply all
Reply to author
Forward
0 new messages