Not able to find play.filters packageAsk Question


I added the dependency for filters in my play framework app as mentioned on this page, however on clean - rebuild, my project is still not able to detect the play.filters... package and it leads to compilation error.

Am I missing something very basic?


This happened to me for the filters library as well, specifically the "" % "filters-helpers_2.11" % "2.4.2" dependency. It should be available from the Maven2 repo and the Typesafe Releases repo. Both of which are implicitly included in SBT's build.sbt file since they are predefined repos in SBT.

My company does all sorts of weird stuff with SSL certs (they basically re-sign them). For my situation I think the true problem was the certificate wasn't trusted by activator since the corporate proxy/firewall messed with it. I was able to fix it by telling activator to not check if the certificate was trusted using a JVM parameter.

To enter the activator shell with cert checks disabled just type:


Then you can compile or run as you normally would and activator/SBT should download dependencies even if they aren't via trusted connections.

Note: I would only do this rarely to download a troublesome dependency into my local cache. Running activator without cert checks is a bit unsafe since downloading untrusted dependencies could leave you open to a trojan/MITM attack.


"clean - rebuild" - are you using Eclipse ?

If so then add eclipse plugin to the play (in plugins.sbt file):

addSbtPlugin("" % "sbt-plugin" % "2.4.3")

Then add to the build.sbt next settings:

// Eclipse settings

// Compile the project before generating Eclipse files,
// so that generated .scala or .class files for views and routes are present
EclipseKeys.preTasks := Seq(compile in Compile)

// Java project. Don't expect Scala IDE
EclipseKeys.projectFlavor := EclipseProjectFlavor.Java

// Use .class files instead of generated .scala files for views and routes
EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources)

// End of eclipse settings

Then run activator eclipse


It seems it was an error in imports. I did an Auto-arrange for imports in Eclipse which removed the following import statement from my Java class:

import play.filters.cors.CORSFilter

Since the import was not present, even when activator was downloading the dependency at build time, it was not able to find the CORSFilter class since Eclipse removed the same while arranging imports. I added the import back again, and though it gives the error in Eclipse that play.filters.cors package not found, but as expected it works fine at the build time.

It looks like a silly error but is difficult to find, so sharing here if anyone else gets the same problem in future.

标签: playframework-2.0 cors
© 2014 TuiCode, Inc.