Reputation: 15435
I have the following test:
import org.scalatestplus.play._
import play.api.test.Helpers._
import play.api.test.{FakeRequest, WsTestClient}
import com.github.andyglow.websocket._
import com.inland24.plantsim.controllers.ApplicationTestFactory
import org.scalatest.WordSpecLike
import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
class EventsWebSocketSpec extends PlaySpec with WordSpecLike
with BaseOneServerPerSuite with ApplicationTestFactory
with ScalaFutures with IntegrationPatience {
private implicit val httpPort = new play.api.http.Port(9000)
"Routes" should {
"send 404 on a bad request" in {
route(app, FakeRequest(GET, "/boum")).map(status) mustBe Some(NOT_FOUND)
}
"send 200 on a good request" in {
route(app, FakeRequest(GET, "/")).map(status) mustBe Some(OK)
}
}
}
I get this error. Seems like the Test is not even started:
Exception encountered when invoking run on a nested suite - org.slf4j.impl.SimpleLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext
java.lang.ClassCastException: org.slf4j.impl.SimpleLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext
Has it got anything to do with some dependency exclusion that I have to do? Here are my dependencies:
libraryDependencies ++= Seq(
ws,
// Our streaming library
"io.monix" %% "monix" % "2.3.3",
"io.monix" %% "monix-cats" % "2.3.3",
// Dependencies needed for Slick
"com.typesafe.slick" %% "slick" % "3.2.0",
"com.typesafe.slick" %% "slick-hikaricp" % "3.2.0",
// For application Metrics
"io.dropwizard.metrics" % "metrics-core" % "4.0.0",
"io.dropwizard.metrics" % "metrics-jvm" % "4.0.0",
"com.typesafe.scala-logging" %% "scala-logging" % "3.8.0",
"org.scala-lang.modules" % "scala-async_2.11" % "0.9.6",
"com.typesafe" % "config" % "1.3.1",
// For JSON parsing
"com.typesafe.play" %% "play-json" % "2.6.0",
"com.typesafe.play" %% "play-json-joda" % "2.6.0",
// JDBC driver for MySQL & H2
"mysql" % "mysql-connector-java" % "5.1.26",
"com.h2database" % "h2" % "1.4.186",
// Swagger UI API Docs
"io.swagger" %% "swagger-play2" % "1.6.0",
"org.webjars" %% "webjars-play" % "2.6.0-M1",
"org.webjars" % "swagger-ui" % "2.2.0",
// Test dependencies
"com.typesafe.akka" %% "akka-testkit" % "2.5.2" % Test,
"org.scalatest" %% "scalatest" % "3.0.1" % Test,
"org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % Test,
"com.github.andyglow" %% "websocket-scala-client" % "0.2.4" % Test
)
Appreciate any help!
EDIT: Upon further exploration, I think the culprit is this slf4j binding:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/joe/.ivy2/cache/org.slf4j/slf4j-simple/jars/slf4j-simple-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/joe/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
How to get rid of this? I know that in my build.sbt for one of the dependency, I have to exclude the slf4j, but which one is that?
Upvotes: 1
Views: 445
Reputation: 15435
By trial and error, I found out that this way of excluding slf4j for two of my dependencies, I was able to fix this!
"org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % Test exclude ("org.slf4j", "slf4j-simple"),
"com.github.andyglow" %% "websocket-scala-client" % "0.2.4" % Test exclude ("org.slf4j", "slf4j-simple")
Upvotes: 1