diff --git a/akka-rest/src/main/scala/ActorComponentProvider.scala b/akka-rest/src/main/scala/ActorComponentProvider.scala index c1d8029425..ed51482604 100644 --- a/akka-rest/src/main/scala/ActorComponentProvider.scala +++ b/akka-rest/src/main/scala/ActorComponentProvider.scala @@ -16,16 +16,14 @@ class ActorComponentProvider(val clazz: Class[_], val configurators: List[Config override def getScope = ComponentScope.Singleton - override def getInstance: Actor = { + override def getInstance: AnyRef = { val instances = for { conf <- configurators if conf.isDefined(clazz) instance <- conf.getInstance(clazz) } yield instance - instances match { - case (instance : Actor) :: Nil => instance - case Nil => throw new IllegalArgumentException("No Actor for class [" + clazz + "] could be found. Make sure you have defined and configured the class as an Active Object or Actor in a Configurator") - case _ => throw new IllegalArgumentException("Actor for class [" + clazz + "] is defined in more than one Configurator. Eliminate the redundancy.") - } + if (instances.isEmpty) throw new IllegalArgumentException( + "No Actor or Active Object for class [" + clazz + "] could be found.\nMake sure you have defined and configured the class as an Active Object or Actor in a supervisor hierarchy.") + else instances.head.asInstanceOf[AnyRef] } } \ No newline at end of file