ProvisionException: Unable to provision, see the following errors:

8,950 views
Skip to first unread message

Wilton

unread,
Dec 13, 2015, 9:29:38 PM12/13/15
to SecureSocial
I'm trying to get an initial configuration of this product working with v. 3.0-M4. I've made a lot of progress and am able to get my app compiled with all of the imports, and I've reused most of the java demo product, but when I launch, I get the following. This obviously has something to do with the injection of the environment, but I'm not very familiar with this, so I'm at a loss to fix it.

ProvisionException: Unable to provision, see the following errors: 1) No implementation for securesocial.core.RuntimeEnvironment was bound. while locating securesocial.core.RuntimeEnvironment for parameter 0 at controllers.Application.<init>(Application.java:38) while locating controllers.Application for parameter 1 at router.Routes.<init>(Routes.scala:44) while locating router.Routes while locating play.api.inject.RoutesProvider while locating play.api.routing.Router 2) No implementation for securesocial.core.RuntimeEnvironment was bound. while locating securesocial.core.RuntimeEnvironment for parameter 0 at securesocial.controllers.PasswordChange.<init>(PasswordChange.scala:38) while locating securesocial.controllers.PasswordChange for parameter 4 at router.Routes.<init>(Routes.scala:44) while locating router.Routes while locating play.api.inject.RoutesProvider while locating play.api.routing.Router 3) No implementation for securesocial.core.RuntimeEnvironment was bound. while locating securesocial.core.RuntimeEnvironment for parameter 0 at securesocial.controllers.ProviderController.<init>(ProviderController.scala:35) while locating securesocial.controllers.ProviderController for parameter 5 at router.Routes.<init>(Routes.scala:44) while locating router.Routes while locating play.api.inject.RoutesProvider while locating play.api.routing.Router 4) No implementation for securesocial.core.RuntimeEnvironment was bound. while locating securesocial.core.RuntimeEnvironment for parameter 0 at securesocial.controllers.Registration.<init>(Registration.scala:41) while locating securesocial.controllers.Registration for parameter 3 at router.Routes.<init>(Routes.scala:44) while locating router.Routes while locating play.api.inject.RoutesProvider while locating play.api.routing.Router 4 errors

com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) No implementation for securesocial.core.RuntimeEnvironment was bound.
  while locating securesocial.core.RuntimeEnvironment
    for parameter 0 at controllers.Application.<init>(Application.java:38)
  while locating controllers.Application
    for parameter 1 at router.Routes.<init>(Routes.scala:44)
  while locating router.Routes
  while locating play.api.inject.RoutesProvider
  while locating play.api.routing.Router

2) No implementation for securesocial.core.RuntimeEnvironment was bound.
  while locating securesocial.core.RuntimeEnvironment
    for parameter 0 at securesocial.controllers.PasswordChange.<init>(PasswordChange.scala:38)
  while locating securesocial.controllers.PasswordChange
    for parameter 4 at router.Routes.<init>(Routes.scala:44)
  while locating router.Routes
  while locating play.api.inject.RoutesProvider
  while locating play.api.routing.Router

3) No implementation for securesocial.core.RuntimeEnvironment was bound.
  while locating securesocial.core.RuntimeEnvironment
    for parameter 0 at securesocial.controllers.ProviderController.<init>(ProviderController.scala:35)
  while locating securesocial.controllers.ProviderController
    for parameter 5 at router.Routes.<init>(Routes.scala:44)
  while locating router.Routes
  while locating play.api.inject.RoutesProvider
  while locating play.api.routing.Router

4) No implementation for securesocial.core.RuntimeEnvironment was bound.
  while locating securesocial.core.RuntimeEnvironment
    for parameter 0 at securesocial.controllers.Registration.<init>(Registration.scala:41)
  while locating securesocial.controllers.Registration
    for parameter 3 at router.Routes.<init>(Routes.scala:44)
  while locating router.Routes
  while locating play.api.inject.RoutesProvider
  while locating play.api.routing.Router

4 errors
     com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1025)
     com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1051)
     play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:321)
     play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:316)
     play.api.Application$class.routes(Application.scala:111)
     play.api.DefaultApplication.routes(Application.scala:240)
     play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:90)
     play.api.Play$$anonfun$start$1.apply(Play.scala:87)
     play.api.Play$$anonfun$start$1.apply(Play.scala:87)
     play.utils.Threads$.withContextClassLoader(Threads.scala:21)
     play.api.Play$.start(Play.scala:87)
     play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:156)
     play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:121)
     scala.Option.map(Option.scala:146)
     play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:121)
     play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:119)
     scala.util.Success.flatMap(Try.scala:231)
     play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:119)
     play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:111)
     scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
     scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
     java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
     java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
     java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:902)
     java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1689)
     java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1644)
     java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

raunak

unread,
Dec 13, 2015, 11:21:00 PM12/13/15
to SecureSocial
I don't know what your code looks like, but at a basic level, you need to do the following. 

1. Extend RunTimeEnvironment like this;

class MyRuntimeEnvironment extends RuntimeEnvironment.Default {

  type U = User;
  override lazy val userService: UserService[U] = new InMemoryUserService();

  override lazy val providers = ListMap (
    // list all the providers you want your app to support
    // full list found here: https://github.com/jaliss/securesocial/blob/master/module-code/app/securesocial/core/RuntimeEnvironment.scala#L82
    include(new UsernamePasswordProvider[ReviewUser](userService, avatarService, viewTemplates, passwordHashers))
  )
}


2. Create package called 'module', and extend AbstractModule like this;

public class SecurityModule extends AbstractModule {

    @Override
    protected void configure() {
        MyRuntimeEnvironment secureEnv = new MyRuntimeEnvironment();
        bind(RuntimeEnvironment.class).toInstance(secureEnv);
    }
}

3. In application.conf, enable SecurityModule like this;
play.modules.enabled = ${play.modules.enabled} ["modules.SecurityModule"]

4. Now, you can inject SecureSocial instances in your controllers, etc like this;
import com.google.inject.Inject;

public
class Application extends Controller {
   
private RuntimeEnvironment env;

    @Inject
   
public Application(RuntimeEnvironment env) {
        this.env = env;
   
}
}




Wilton

unread,
Dec 15, 2015, 1:52:57 AM12/15/15
to SecureSocial

This helped a lot, thanks!  It was part (3) that was missing from my configuration. Sneaky guy. 

Now I'm seeing this:

[ConfigurationException: Guice configuration errors: 1) Could not find a suitable constructor in securesocial.core.java.UserAware. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private. at securesocial.core.java.UserAware.class(UserAware.java:46) while locating securesocial.core.java.UserAware 1 error]

raunak

unread,
Dec 15, 2015, 6:20:12 AM12/15/15
to SecureSocial
I see - I think its a bug. Will submit a fix to repo now ;)

raunak

unread,
Dec 15, 2015, 6:47:50 AM12/15/15
to SecureSocial
Here's the PR for your troubles: https://github.com/jaliss/securesocial/pull/576. When it gets merged with the main repo, you should be good to go.

In theory, if you create a copy of UserAware with the code here, and use that UserAware annotation, that should also fix the problem. 

Jorge Aliss

unread,
Dec 15, 2015, 9:14:06 AM12/15/15
to SecureSocial
Just merged your pull request Raunak and updated master snapshot with it.  
Thanks!

Jorge

Wilton

unread,
Dec 15, 2015, 11:47:00 AM12/15/15
to SecureSocial

Awesome! Thank you so much! That was fast!

Wilton

unread,
Dec 16, 2015, 1:41:02 AM12/16/15
to SecureSocial

Just pulled the latest master-SNAPSHOT and the error I was experiencing before is gone. I've now got a login page - Huzzah!

raunak

unread,
Dec 16, 2015, 6:26:36 AM12/16/15
to SecureSocial
I'm glad it worked :)
Reply all
Reply to author
Forward
0 new messages