Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guice configuration errors: Could not find suitable constructor in controllers #36

Open
mehayden opened this issue May 20, 2014 · 5 comments

Comments

@mehayden
Copy link

I am trying to define a custom REST controller as per custom-rest-controllers.md. It compiles and runs the list method correctly, but then it gets an exception, seemingly to do with dynamic controller routes, although the routes are not defined with '@'. Here is the error and stack trace:

com.google.inject.ConfigurationException: Guice configuration errors:

  1. Could not find a suitable constructor in controllers.LinkRestController. Clas
    ses must have either one (and only one) constructor annotated with @Inject or a
    zero-argument constructor that is not private.
    at controllers.LinkRestController.class(LinkRestController.java:21)
    while locating controllers.LinkRestController

1 error
at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java
:1004)
at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java
:961)
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java
:1013)
at play.utils.inject.InjectAdapter.getInstance(InjectAdapter.java:34)
at play.utils.crud.CRUDManager.getController(CRUDManager.java:59)
at play.utils.crud.GlobalCRUDSettings.getControllerInstance(GlobalCRUDSe
ttings.java:12)
at play.utils.meta.cp.ClasspathScanningControllerRegistry.scanRest(Class
pathScanningControllerRegistry.java:116)
at play.utils.meta.cp.ClasspathScanningControllerRegistry.(Classpa
thScanningControllerRegistry.java:45)
at play.utils.crud.CRUDManager.initialize(CRUDManager.java:45)
at play.utils.crud.GlobalCRUDSettings.onStart(GlobalCRUDSettings.java:23
)
at play.core.j.JavaGlobalSettingsAdapter.onStart(JavaGlobalSettingsAdapt
er.scala:18)
at play.api.GlobalPlugin.onStart(GlobalSettings.scala:203)
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.sca
la:88)
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.sca
la:88)
at scala.collection.immutable.List.foreach(List.scala:318)
at play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:88)
at play.api.Play$$anonfun$start$1.apply(Play.scala:88)
at play.api.Play$$anonfun$start$1.apply(Play.scala:88)
at play.utils.Threads$.withContextClassLoader(Threads.scala:18)
at play.api.Play$.start(Play.scala:87)
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anon
fun$1.apply(ApplicationProvider.scala:139)
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anon
fun$1.apply(ApplicationProvider.scala:112)
at scala.Option.map(Option.scala:145)
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply
(ApplicationProvider.scala:112)
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply
(ApplicationProvider.scala:110)
at scala.util.Success.flatMap(Try.scala:200)
at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvi
der.scala:110)
at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvi
der.scala:102)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(
Future.scala:24)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.sca
la:24)
at scala.concurrent.forkjoin.ForkJoinTask$AdaptedRunnableAction.exec(For
kJoinTask.java:1361)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool
.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:19
79)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThre
ad.java:107)
[info] play - Application started (Dev)

@hakandilek
Copy link
Owner

Does LinkRestController have a zero-argument public constructor? Or one with @Inject annotation?

@hakandilek
Copy link
Owner

This seems to be similar to #42 which is fixed. Please try again with the latest snapshot version and tell me if you still experience the same problem. Otherwise we may close this bug.

@bluepoet
Copy link

+1

@mehayden
Copy link
Author

Sorry, I'm no longer working on this app and have no way to verify, so close if you like.

@proton5000
Copy link

I have the same problem. I can not solve it. Please help me. I am trying to update play framework 2.3.10 to 2.4.1 and got this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants