7

In order to use WebJars in my Play app I've added the following route

GET     /webjars/*file              controllers.WebJarAssets.at(file)

In my scala template I've added the following lines:

<link rel='stylesheet' href='@routes.WebJarAssets.at(WebJarAssets.locate("css/bootstrap.min.css"))'>
<link rel='stylesheet' href='@routes.WebJarAssets.at(WebJarAssets.locate("css/bootstrap-theme.min.css"))'>

When I open the app, the css files are perfectly loaded. But as soon as I run activator eclipse, I get the following compilation error:

[info] Compiling 4 Scala sources and 2 Java sources to /Users/d135-1r43/play/blog/target/scala-2.11/classes...
[error] /Users/d135-1r43/play/blog/conf/routes:10: object WebJarAssets is not a member of package controllers
[error] GET     /webjars/*file              controllers.WebJarAssets.at(file)
[error] /Users/d135-1r43/play/blog/conf/routes:10: object WebJarAssets is not a member of package controllers
[error] GET     /webjars/*file              controllers.WebJarAssets.at(file)
[error] /Users/d135-1r43/play/blog/app/views/main.scala.html:8: not found: value WebJarAssets
[error]         <link rel='stylesheet' href='@routes.WebJarAssets.at(WebJarAssets.locate("css/bootstrap.min.css"))'>
[error]                                                              ^
[error] /Users/d135-1r43/play/blog/app/views/main.scala.html:9: not found: value WebJarAssets
[error]         <link rel='stylesheet' href='@routes.WebJarAssets.at(WebJarAssets.locate("css/bootstrap-theme.min.css"))'>
[error]                                                              ^
[error] four errors found
[error] (compile:compile) Compilation failed
[error] Could not create Eclipse project files:
[error] Error evaluating task 'dependencyClasspath': error

Any idea what happened here? Do I need to add something to my classpath?

Jacek Laskowski
  • 64,943
  • 20
  • 207
  • 364
d135-1r43
  • 2,461
  • 1
  • 22
  • 33
  • 6
    Is `webjars-play`among your dependencies? You need to add it to your build file: `libraryDependencies += "org.webjars" %% "webjars-play" % "2.3.0-2"` – Nader Ghanbari Dec 20 '14 at 10:55

1 Answers1

5

I have faced the same error, adding following line in my build.sbt file solved the issue.

libraryDependencies += "org.webjars" %% "webjars-play" % "2.4.0"

Vinay
  • 1,181
  • 2
  • 11
  • 17