These are chat archives for adamw/macwire

9th
Oct 2017
Christian Kaps
@akkie
Oct 09 09:25

I currently try to wire an actor with an implicit parameter. The project compiles but I get an IllegalArgumentException at runtime.

The constructor looks as follow:

class Connector(brokerService: BrokerService)(
  implicit
  ec: ExecutionContext
) extends Actor with LazyLogging

The error is the follow:

java.lang.IllegalArgumentException: no matching constructor found on class app.actors.Connector for arguments [class app.models.services.BrokerServiceImpl]

If I remove the implicit parameter, all works as expected.

Adam Warski
@adamw
Oct 09 10:35
@akkie can you post your Props?
Christian Kaps
@akkie
Oct 09 11:27
@adamw I instantiate the actor with val connector: ActorRef = wireActor[Connector]("connector") The BrokerService is injected in the class which instantiates the connector actor.
Adam Warski
@adamw
Oct 09 15:14
ah, this unwraps to Props(classOf[Connector], brokerService) which is the non-typesafe way of creating new instances of actors
and is (or at least was) recommended some time ago as "the" way to do things
if we would instead unwrap to Props(new Connector(brokerService)) things would work fine
@akkie can you file a bug?
I'll see if this is fixable easily :)
or of course if you would like to try fixing yourself, that would be even better :)