I am transferring a project from Play 2.2.4 to 2.4.2, and I get an exception that I cannot understand and solve.
Unexpected exception
ProvisionException: Unable to provision, see the following errors:
1) Error injecting constructor, java.lang.NullPointerException
at controllers.Application.<init>(Application.java:33)
while locating controllers.Application
for parameter 1 at router.Routes.<init>(Routes.scala:36)
while locating router.Routes
while locating play.api.inject.RoutesProvider
while locating play.api.routing.Router
1 error
This happens because I added dependency injection for the WS API, for example:
public class Application extends Controller {
@Inject
WSClient ws;
WSRequest request = ws.url("https://...");
...
}
The file build.sbtcontains the necessary configuration.
libraryDependencies ++= Seq(
javaJdbc,
cache,
javaWs
)
// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator
What could be missing or done wrong?
source
share