MacWire: Found multiple values of type

1.1k views Asked by At

I'm using MacWire DI framework and I'm geting this error.

Found multiple values of type [play.api.mvc.DefaultActionBuilder]: [List(defaultActionBuilder, Action)]
[error]   override lazy val controllerComponents: DefaultControllerComponents = wire[DefaultControllerComponents]

My applicatopn Loader is this:

class AppApplicationLoader extends ApplicationLoader {
  def load(context: Context) = {
    LoggerConfigurator(context.environment.classLoader).foreach { cfg =>
      cfg.configure(context.environment)
    }
    new AppComponents(context).application
  }
}

 class AppComponents(context: Context) extends
      BuiltInComponentsFromContext(context) with AhcWSComponents
      with AssetsComponents with HttpFiltersComponents
      with EvolutionsComponents with DBComponents  with HikariCPComponents  with EhCacheComponents {

      override lazy val controllerComponents: DefaultControllerComponents = wire[DefaultControllerComponents]

I've been getting some other errors similar after small modifications of the code. How can I follow DI dependencies to track down these errors?

1

There are 1 answers

0
Roberto Tyley On

Just encountered this myself, it appears to be due to this commit, which was included as a backport in Play 2.6.3:

https://github.com/playframework/playframework/pull/7676/files/809cd1e880b01d45e95d41e65f20bfa984d1e122#r138400765

...so code that compiles with Play 2.6.2 fails with Play 2.6.3.

Workarounds:

  • Revert to Play 2.6.2, or...
  • ...manually specify the creation of your DefaultControllerComponents - ie don't use MacWire for that particular constructor

That's not as pretty, but it works with Play 2.6.3:

val defaultControllerComponents = new DefaultControllerComponents(
  defaultActionBuilder,
  playBodyParsers,
  messagesApi,
  langs,
  fileMimeTypes,
  executionContext
)