Reason for "could not find implicit value for parameter rs: spray.routing.RoutingSettings"

While exactly following (or so I thought) the example at https://github.com/spray/spray-template/blob/on_spray-can_1.3/src/main/scala/com/example/MyService.scala I ran into this error:

[error] /Users/alias/dev/src/main/scala/framework/MyActor.scala:86: could not find implicit value for parameter rs: spray.routing.RoutingSettings
[error]   def receive = runRoute(routes)
[error] 

and couldn't figure out why the seemingly same code didn't work.

Upvotes: 2

Views: 2380

Answers (2)

mingchuno
mingchuno

Reputation: 557

try to add: def actorRefFactory = context

Upvotes: 1

I found this which pointed me in the right direction for debugging the issue using implicitly

implicitly[RoutingSettings]

From there I was able to determine that there was an ambiguous implicit

Multiple markers at this line
    - implicit ActorRefFactory required: if outside of an Actor you need an implicit ActorSystem, inside of an actor this should be the implicit ActorContext
    - not enough arguments for method default: (implicit refFactory: akka.actor.ActorRefFactory)spray.routing.RoutingSettings. Unspecified value parameter 
     refFactory.
    - ambiguous implicit values: both value context in trait Actor of type => akka.actor.ActorContext and method system in trait ActorContext of type => 
     akka.actor.ActorSystem match expected type akka.actor.ActorRefFactory

Which I eventually worked out was being caused by import context._ in my Actor

This took me FAR too long to work out, so hopefully this will save people a lot of time in future!

Upvotes: 4

Related Questions