3

I'm working through some compilation errors (in Scala / Play Framework) and one I can't resolve is a conflict error. This is the error:

class Games inherits conflicting members:

[error] method parse in trait BaseControllerHelpers of type => play.api.mvc.PlayBodyParsers and

[error] lazy value parse in trait BodyParsers of type play.api.mvc.PlayBodyParsers [error] (Note: this can be resolved by declaring an override in class Games.)

And this is the function (or class) signature for the class:

   class Games @Inject() (cc: ControllerComponents, actorSystem: ActorSystem)(val reactiveMongoApi: ReactiveMongoApi)(implicit mat: Materializer) extends AbstractController(cc) with MongoController with ReactiveMongoComponents {

In the error message you'll notice that it says that:

this can be resolved by declaring an override in class Games

But after having tried a few things - I am not sure how. If anyone has any suggestions on this or any other technique that could resolve this error please post. Thanks

Community
  • 1
  • 1
  • 1
    There is conflict between the new (Play 2.6) `AbstractController` and `MongoController`, the former being based on the deprecated `Controller` trait. Play 2.6 backward compat prevent such mix of `AbstractController` / `Controller`. Until that's fix the only workaround is to remove. – cchantep Aug 02 '17 at 23:38
  • @cchantep thanks. If this is the issue why does neither the *ReactiveMongo* or *Play Framework* documentation acknowledge this? There's information on how to integrate them here - http://reactivemongo.org/releases/0.12/documentation/tutorial/play.html so why wouldn't they have tested them? Seems totally ridiculous. So is the answer not to use Play 2.6? – jesus g_force Harris Aug 03 '17 at 10:28
  • @cchantep and also - is there really no *override* that can resolve this? – jesus g_force Harris Aug 03 '17 at 10:30
  • I can hardly see a way with the inheritance changes in Play MVC – cchantep Aug 03 '17 at 10:39
  • Having the same issue, what is the solution here? This kind of thing has happened every time I've tried getting started with Play – samsquanch Aug 05 '17 at 18:36
  • 2
    @jesusg_forceHarris You can work around the issue by adding this override to your controller: `override lazy val parse: PlayBodyParsers = cc.parsers` – samsquanch Aug 05 '17 at 18:59
  • You can try ReactiveMongo 0.12.5-SNAPSHOT – cchantep Aug 07 '17 at 23:02
  • @samsquanch Thanks it got rid of the error but I have noticed that on some pages I am getting a "Unauthorized. You must be authenticated to access this page." - which I never saw with Play 2.5. I'll look into it tomorrow – jesus g_force Harris Aug 08 '17 at 21:56
  • @samsquanch - feel free to put your solution in an answer and I will mark it correct. Thanks again – jesus g_force Harris Sep 12 '17 at 12:48
  • I had this issue on play 2.6.7 and reactivemongo 0.12.7 and scala 2.12.4. @cchantep's suggestion works perfectly. removed `play.modules.reactivemongo.MongoController` from the class inherits. – mcku Nov 24 '17 at 20:06

0 Answers0