11
votes

Occasionally, and seemingly for no reason, I get "not found: value routes" compilation error in one of the view templates (after compilation). This happens either in Eclipse or IDEA.

Googling finds this but it's not possible to add mainLang = SCALA in play 2.10 (I'm using version 2.1.2).

Cleaning the project / re-eclipsifying it / seems to work, sometimes, but is there any more permenant solution / work-around?

Thanks

9
I had the same issue and I found the solution. Seems like the controllers package is not imported, try to rewrite your code with something like this @controllers.routes.Assets.at(...), or add TwirlKeys.templateImports += "controllers._" in setting of your project in build.sbt or Build.scala file. - andrey.feoktistov

9 Answers

5
votes

Since there seems to be no answer, I'll at-least describe my workaround: Instead of using

<link [email protected]("stylesheets/style.css") rel="stylesheet" type="text/css" />

in my template HTML, I'm using

<link href="assets/stylesheets/styles.css") rel="stylesheet" type="text/css" />

Since I'm not invoking routes.Assets.at, there is no issue with not finding the value routes. (However, I'm guessing this workaround will easily crumble when I would have need of more complex templates)

4
votes

This can happen if the routes file does not exist or contains no routes.

1
votes

I have this working defining an Asset Controller

object Assets extends controllers.AssetsBuilder

and having the route for assets too in the routes conf:

\#Map static resources from the /public folder to the /assets URL path
GET     /assets/*file          premise.internet_org.controllers.Assets.at(path="/public", file)
1
votes
sbt compile

Then IntelliJ loads the output of the compilation and everything just works for me.

0
votes

This happens when there is no route configuration for your Assets in the routes file.

You must add this to your routes file:

GET   /assets/*file  controllers.Assets.at(path="/public", file)
0
votes

I had such error when tried build Sihouette example project https://github.com/mohiva/play-silhouette-seed/tree/master. I commented or replaced code, that caused error. For example:


    def view = silhouette.UnsecuredAction.async { implicit request: Request[AnyContent] =>
        //Future.successful(Ok(views.html.signUp(SignUpForm.form)))
       Future.successful(Ok)
    }

After that build become successful - Twirl and Routes directories created in target/scala-2.X/. I run application and restore original code.


    def view = silhouette.UnsecuredAction.async { implicit request: Request[AnyContent] =>
        Future.successful(Ok(views.html.signUp(SignUpForm.form)))
    }
0
votes

I had added .disablePlugins(PlayLayoutPlugin) to my built.sbt "root" definition without changing the directory structure to match (see the link below explaining this). It switches from "Play application layout" to the "default sbt layout". The routes and application.conf are now expected in a different location on disk. I encountered both "not found: value routes" and "resource not found on classpath: application.conf" errors. I had copied this disablePlugins line from another project.

https://www.playframework.com/documentation/2.8.x/Anatomy#Default-sbt-layout

0
votes

I had the same problem, its resolved when i drop the generated folders (target) and i restart my application

-1
votes

I had to go to the terminal and type "activator test" before Intellij would stop giving me these errors during IDE tests.