scala - Play Dependency Injection Error -


i trying use di inject webservice client in application. runtime exception refer current application in object being injected. below skeletal of code.

    **import play.api.play.current**     @singleton     class micorserviceclient@inject()(ws: wsclient) {       // references curret.configuraiton.getstring(     ....     }     class application @inject()(microserviceclient: micorserviceclient) extends controller {         def somemethod= action {        //calls micorservicelient.getresponse()        }     } 

i see following error when api called.

@709lj5bmd: unexpected exception     @ play.core.server.devserverstart$$anonfun$maindev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(devserverstart.scala:170)     @ play.core.server.devserverstart$$anonfun$maindev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(devserverstart.scala:126)     @ scala.option.map(option.scala:146)     @ play.core.server.devserverstart$$anonfun$maindev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(devserverstart.scala:126)     @ play.core.server.devserverstart$$anonfun$maindev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(devserverstart.scala:124)     @ scala.util.success.flatmap(try.scala:231)     @ play.core.server.devserverstart$$anonfun$maindev$1$$anon$1$$anonfun$get$1.apply(devserverstart.scala:124)     @ play.core.server.devserverstart$$anonfun$maindev$1$$anon$1$$anonfun$get$1.apply(devserverstart.scala:116)     @ 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:1402)     @ java.util.concurrent.forkjointask.doexec(forkjointask.java:289)     @ java.util.concurrent.forkjoinpool$workqueue.runtask(forkjoinpool.java:1056)     @ java.util.concurrent.forkjoinpool.runworker(forkjoinpool.java:1689)     @ java.util.concurrent.forkjoinworkerthread.run(forkjoinworkerthread.java:157) caused by: com.google.inject.provisionexception: unable provision, see following errors:  1) error injecting constructor, java.lang.runtimeexception: there no started application 

ah, solved issue, need pass play.api.configuration client , remove references current

so microserviceclient definition looks below

class microserviceclient(ws: wsclient, configuration: play.api.configuration) { } 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo