I then defined a controller
class CodingCtrl @Inject()(cc: ControllerComponents,
authenticatedAction: AuthenticatedAction)
extends AbstractController(cc)
and it fails
If I use
class CodingCtrl(codingService:CodingService) (cc: ControllerComponents)
extends AbstractController(cc) {
It works.
How can I handle this so I can pull in AuthenticatedAction while wiring in CodingService as well ?
Thank you
The problem seems to be with
Cannot find a value of type: [play.api.mvc.BodyParsers.Default]
I am importing in
import play.api.mvc.BodyParsers._
import play.api.mvc.BodyParsers
and tried with LoggingAction to see it that works. Have the same issue - seems like an issue with BodyParsers ?
Hi Adam,
Thanks for your response I have the trait
trait CodingModule extends ServicesModule {
import com.softwaremill.macwire._
lazy val AuthenticatedAction = wire[AuthenticatedAction]
lazy val CodingCtrl = wire[CodingCtrl]
def controllerComponents: ControllerComponents
}
and AuhenticatedAction as
…
class AuthenticatedAction @Inject()(parser: BodyParsers.Default)
(implicit ec: ExecutionContext) extends ActionBuilderImpl(parser) {
…
I am trying to inject AuthenticatedAction into my controller and I get the following message when I compile
Cannot find a value of type: [play.api.mvc.BodyParsers.Default]
[error] lazy val AuthenticatedAction = wire[AuthenticatedAction]
Seems like it’s unable to wire play.api.mvc.BodyParsers.Default - Default ?
I did import - play.api.mvc.BodyParsers._
Not sure if the above information is sufficient to know the cause or you need more info.
I didn’t use Play for a long time, but looking at the code (the constructors), to create BodyParsers.Default), you need a PlayBodyParsers instance. To create that, you need to instantiate DefaultPlayBodyParsers, which has its own dependencies etc.