diff --git a/akka-discovery/src/main/scala/akka/discovery/Discovery.scala b/akka-discovery/src/main/scala/akka/discovery/Discovery.scala index ab1ef0e2c5..952f9c68d8 100644 --- a/akka-discovery/src/main/scala/akka/discovery/Discovery.scala +++ b/akka-discovery/src/main/scala/akka/discovery/Discovery.scala @@ -115,7 +115,11 @@ object Discovery extends ExtensionId[Discovery] with ExtensionIdProvider { throw new RuntimeException( "Old version of Akka Discovery from Akka Management found on the classpath. Remove `com.lightbend.akka.discovery:akka-discovery` from the classpath..") } catch { - case _: ClassNotFoundException => // all good + case _: ClassCastException ⇒ + throw new RuntimeException( + "Old version of Akka Discovery from Akka Management found on the classpath. Remove `com.lightbend.akka.discovery:akka-discovery` from the classpath..") + case _: ClassNotFoundException => + // all good } }