Scala Play compile time DI with Java controller

I’m working with Lagom 1.4 (Play 2.6). The Play app is an external facing API gateway. It is bootstrapped with compile-time DI. I’m trying to integrate with play-pac4j. Play-pac4j ships with a couple Play controllers that handle authentication flow. The controllers are implemented in Java. I want to ask if there is any sample in how to initialize Java controllers for Play Scala compile-time dependency injection.

I’m able to construct the Java controller and wire that into the generated Routes() class constructor. However, when I run and try to hit the path that goes to the Java controller, I’m getting a AkkaHttpServer error:

[ERROR] [03/25/2019 16:41:39.968] [portalApiGateway-internal-dev-mode-akka.actor.default-dispatcher-2] [akka.actor.ActorSystemImpl(portalApiGateway-internal-dev-mode)] Internal server error, sending 500 response
java.lang.RuntimeException: AkkaHttpServer doesn't handle Handlers of this type: play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$3$$anon$4@855015d
        at scala.sys.package$.error(package.scala:30)
        at play.core.server.AkkaHttpServer.executeHandler(AkkaHttpServer.scala:337)
        at play.core.server.AkkaHttpServer.handleRequest(AkkaHttpServer.scala:263)
        at play.core.server.AkkaHttpServer.$anonfun$createServerBinding$1(AkkaHttpServer.scala:138)
        at akka.stream.impl.fusing.MapAsyncUnordered$$anon$31.onPush(Ops.scala:1318)
        at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:519)
        at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:482)

Thanks for looking into this

Hey @kc,

Could you please create a small project that reproduces this problem?

Best

Thanks for looking into the issue. Here is a simple project that illustrates the issue:

I understand that I should use JavaCompatibleHttpRequestHandler to handle the request. However, to pull in the dependent JavaHandlerComponents, it has to pull in a lot of conflicting Java version of Components.

Thanks again.