New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassCastException: com.twitter.finatra.logging.FinagleMDCAdapter cannot be cast to ch.qos.logback.classic.util.LogbackMDCAdapter #256

Closed
schrepfler opened this Issue Sep 22, 2015 · 3 comments

Comments

3 participants
@schrepfler

schrepfler commented Sep 22, 2015

java.lang.ClassCastException: com.twitter.finatra.logging.FinagleMDCAdapter cannot be cast to ch.qos.logback.classic.util.LogbackMDCAdapter

With these versions and dependencies

lazy val versions = new {
  val finatra = "2.0.1";
  val logback = "1.0.13";
  val finagleMetrics = "0.0.2";
  val wurflJava = "1.6.2.1";
  val commonsCollections = "3.2.1";
  val commonsLang = "2.6";
  val jsr107 = "1.1";
  val ehCache = "2.4.3";
  val mockito = "1.9.5";
  val scalaTest = "2.2.3";
  val specs2 = "2.3.12";
}

libraryDependencies ++= Seq(
  "com.twitter.finatra" %% "finatra-http" % versions.finatra,
  "com.twitter.finatra" %% "finatra-httpclient" % versions.finatra,
  "com.twitter.finatra" %% "finatra-utils" % versions.finatra,
  "com.twitter.finatra" %% "finatra-slf4j" % versions.finatra,
  "ch.qos.logback" % "logback-classic" % versions.logback,
  "com.twitter.finatra" %% "finatra-http" % versions.finatra % "test",
  "com.twitter.finatra" %% "finatra-jackson" % versions.finatra % "test",
  "com.twitter.finatra" %% "finatra-jackson" % versions.finatra % "test" classifier "tests",
  "com.twitter.inject" %% "inject-server" % versions.finatra % "test",
  "com.twitter.inject" %% "inject-app" % versions.finatra % "test",
  "com.twitter.inject" %% "inject-core" % versions.finatra % "test",
  "com.twitter.inject" %% "inject-modules" % versions.finatra % "test",
  "com.twitter.finatra" %% "finatra-http" % versions.finatra % "test" classifier "tests",
  "com.twitter.inject" %% "inject-server" % versions.finatra % "test" classifier "tests",
  "com.twitter.inject" %% "inject-app" % versions.finatra % "test" classifier "tests",
  "com.twitter.inject" %% "inject-core" % versions.finatra % "test" classifier "tests",
  "com.twitter.inject" %% "inject-modules" % versions.finatra % "test" classifier "tests",
  "com.github.rlazoti" %% "finagle-metrics" % versions.finagleMetrics,
  "net.sourceforge.wurfl" % "wurfl" % versions.wurflJava,
  "commons-collections" % "commons-collections" % versions.commonsCollections,
  "commons-lang" % "commons-lang" % versions.commonsLang,
  "net.sf.jsr107cache" % "jsr107cache" % versions.jsr107,
  "net.sf.ehcache" % "ehcache-core" % versions.ehCache,
  "org.mockito" % "mockito-core" % versions.mockito % "test",
  "org.scalatest" %% "scalatest" % versions.scalaTest % "test",
  "org.specs2" %% "specs2" % versions.specs2 % "test")

I'm getting the following stack trace

[error] java.lang.ClassCastException: com.twitter.finatra.logging.FinagleMDCAdapter cannot be cast to ch.qos.logback.classic.util.LogbackMDCAdapter
[error]     at ch.qos.logback.classic.spi.LoggingEvent.<init>(LoggingEvent.java:133)
[error]     at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:471)
[error]     at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:427)
[error]     at ch.qos.logback.classic.Logger.info(Logger.java:631)
[error]     at grizzled.slf4j.Logger.info(slf4j.scala:128)
[error]     at grizzled.slf4j.Logging$class.info(slf4j.scala:268)
[error]     at com.wh.wurfl.finatra.WurflServer.info(WurflServer.scala:22)
[error]     at com.twitter.inject.app.App$class.main(App.scala:50)
[error]     at com.wh.wurfl.finatra.WurflServer.com$twitter$inject$server$TwitterServer$$super$main(WurflServer.scala:22)
[error]     at com.twitter.inject.server.TwitterServer$class.main(TwitterServer.scala:32)
[error]     at com.wh.wurfl.finatra.WurflServer.main(WurflServer.scala:22)
[error]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]     at java.lang.reflect.Method.invoke(Method.java:497)
[error]     at com.twitter.app.App$$anonfun$nonExitingMain$3.apply(App.scala:168)
[error]     at com.twitter.app.App$$anonfun$nonExitingMain$3.apply(App.scala:167)
[error]     at scala.Option.foreach(Option.scala:257)
[error]     at com.twitter.app.App$class.nonExitingMain(App.scala:167)
[error]     at com.wh.wurfl.finatra.WurflServer.nonExitingMain(WurflServer.scala:22)
[error]     at com.twitter.app.App$class.main(App.scala:133)
[error]     at com.wh.wurfl.finatra.WurflServer.main(WurflServer.scala:22)
[error]     at com.wh.wurfl.finatra.WurflServerMain.main(WurflServer.scala)

I also notice this warning in the logs but the latest logback is chosen and it's the same used to compile finatra.

12:39:48 SBT project import
         [warn] There may be incompatibilities among your library dependencies.
         [warn] Here are some of the libraries that were evicted:
         [warn]     * ch.qos.logback:logback-classic:0.9.28 -> 1.0.13
         [warn] Run 'evicted' to see detailed eviction warnings
@scosenza

This comment has been minimized.

Contributor

scosenza commented Sep 22, 2015

You'll need to exclude older versions of logback-classic (0.9.28) being
included by your non Finatra dependencies. What's the SBT output
after running "evicted"?

On Tuesday, September 22, 2015, Srepfler Srdan notifications@github.com
wrote:

java.lang.ClassCastException:
com.twitter.finatra.logging.FinagleMDCAdapter cannot be cast to
ch.qos.logback.classic.util.LogbackMDCAdapter

With these versions and dependencies

lazy val versions = new {
val finatra = "2.0.1";
val logback = "1.0.13";
val finagleMetrics = "0.0.2";
val wurflJava = "1.6.2.1";
val commonsCollections = "3.2.1";
val commonsLang = "2.6";
val jsr107 = "1.1";
val ehCache = "2.4.3";
val mockito = "1.9.5";
val scalaTest = "2.2.3";
val specs2 = "2.3.12";
}

libraryDependencies ++= Seq(
"com.twitter.finatra" %% "finatra-http" % versions.finatra,
"com.twitter.finatra" %% "finatra-httpclient" % versions.finatra,
"com.twitter.finatra" %% "finatra-utils" % versions.finatra,
"com.twitter.finatra" %% "finatra-slf4j" % versions.finatra,
"ch.qos.logback" % "logback-classic" % versions.logback,
"com.twitter.finatra" %% "finatra-http" % versions.finatra % "test",
"com.twitter.finatra" %% "finatra-jackson" % versions.finatra % "test",
"com.twitter.finatra" %% "finatra-jackson" % versions.finatra % "test" classifier "tests",
"com.twitter.inject" %% "inject-server" % versions.finatra % "test",
"com.twitter.inject" %% "inject-app" % versions.finatra % "test",
"com.twitter.inject" %% "inject-core" % versions.finatra % "test",
"com.twitter.inject" %% "inject-modules" % versions.finatra % "test",
"com.twitter.finatra" %% "finatra-http" % versions.finatra % "test" classifier "tests",
"com.twitter.inject" %% "inject-server" % versions.finatra % "test" classifier "tests",
"com.twitter.inject" %% "inject-app" % versions.finatra % "test" classifier "tests",
"com.twitter.inject" %% "inject-core" % versions.finatra % "test" classifier "tests",
"com.twitter.inject" %% "inject-modules" % versions.finatra % "test" classifier "tests",
"com.github.rlazoti" %% "finagle-metrics" % versions.finagleMetrics,
"net.sourceforge.wurfl" % "wurfl" % versions.wurflJava,
"commons-collections" % "commons-collections" % versions.commonsCollections,
"commons-lang" % "commons-lang" % versions.commonsLang,
"net.sf.jsr107cache" % "jsr107cache" % versions.jsr107,
"net.sf.ehcache" % "ehcache-core" % versions.ehCache,
"org.mockito" % "mockito-core" % versions.mockito % "test",
"org.scalatest" %% "scalatest" % versions.scalaTest % "test",
"org.specs2" %% "specs2" % versions.specs2 % "test")

I'm getting the following stack trace

[error] java.lang.ClassCastException: com.twitter.finatra.logging.FinagleMDCAdapter cannot be cast to ch.qos.logback.classic.util.LogbackMDCAdapter
[error] at ch.qos.logback.classic.spi.LoggingEvent.(LoggingEvent.java:133)
[error] at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:471)
[error] at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:427)
[error] at ch.qos.logback.classic.Logger.info(Logger.java:631)
[error] at grizzled.slf4j.Logger.info(slf4j.scala:128)
[error] at grizzled.slf4j.Logging$class.info(slf4j.scala:268)
[error] at com.wh.wurfl.finatra.WurflServer.info(WurflServer.scala:22)
[error] at com.twitter.inject.app.App$class.main(App.scala:50)
[error] at com.wh.wurfl.finatra.WurflServer.com$twitter$inject$server$TwitterServer$$super$main(WurflServer.scala:22)
[error] at com.twitter.inject.server.TwitterServer$class.main(TwitterServer.scala:32)
[error] at com.wh.wurfl.finatra.WurflServer.main(WurflServer.scala:22)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.lang.reflect.Method.invoke(Method.java:497)
[error] at com.twitter.app.App$$anonfun$nonExitingMain$3.apply(App.scala:168)
[error] at com.twitter.app.App$$anonfun$nonExitingMain$3.apply(App.scala:167)
[error] at scala.Option.foreach(Option.scala:257)
[error] at com.twitter.app.App$class.nonExitingMain(App.scala:167)
[error] at com.wh.wurfl.finatra.WurflServer.nonExitingMain(WurflServer.scala:22)
[error] at com.twitter.app.App$class.main(App.scala:133)
[error] at com.wh.wurfl.finatra.WurflServer.main(WurflServer.scala:22)
[error] at com.wh.wurfl.finatra.WurflServerMain.main(WurflServer.scala)

I also notice this warning in the logs but the latest logback is chosen
and it's the same used to compile finatra.

12:39:48 SBT project import
[warn] There may be incompatibilities among your library dependencies.
[warn] Here are some of the libraries that were evicted:
[warn] * ch.qos.logback:logback-classic:0.9.28 -> 1.0.13
[warn] Run 'evicted' to see detailed eviction warnings


Reply to this email directly or view it on GitHub
#256.

-Steve

Sent from Gmail Mobile

@schrepfler

This comment has been minimized.

schrepfler commented Sep 23, 2015

> evicted
[info] Updating {file:/Users/schrepfler/Documents/sources/wurfl-microservice/}wurfl-microservice...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies.
[warn] Here are some of the libraries that were evicted:
[warn]  * ch.qos.logback:logback-classic:0.9.28 -> 1.0.13 (caller: net.sourceforge.wurfl:wurfl:1.6.2.1, com.williamhill.uwurfl:uwurfl_2.11:1.4-SNAPSHOT)
[warn]  * com.twitter:finagle-core_2.11:6.24.0 -> 6.28.0 (caller: com.twitter.inject:inject-request-scope_2.11:2.0.1 (), com.twitter:finagle-httpx_2.11:6.28.0 (), com.twitter:finagle-http_2.11:6.28.0 (), com.twitter:finagle-zipkin_2.11:6.28.0 (), com.twitter:finagle-httpx-compat_2.11:6.28.0 (), com.twitter:finagle-stats_2.11:6.28.0 (), com.twitter.inject:inject-modules_2.11:2.0.1 (), com.twitter:finagle-thrift_2.11:6.28.0 (), com.github.rlazoti:finagle-metrics_2.11:0.0.2, com.twitter:twitter-server_2.11:1.13.0 ())
[warn]  * com.google.guava:guava:15.0 -> 16.0.1 (caller: com.twitter.common:quantity:0.0.98, com.twitter:finagle-httpx_2.11:6.28.0 (), com.twitter.common:util-system-mocks:0.0.103, com.twitter.common:stats-provider:0.0.92, com.twitter:finagle-http_2.11:6.28.0 (), com.twitter:finagle-zipkin_2.11:6.28.0 (), com.twitter.inject:inject-core_2.11:2.0.1 (), com.twitter:finagle-stats_2.11:6.28.0 (), com.twitter.common:jdk-logging:0.0.79, com.twitter.common:util-executor-service-shutdown:0.0.66, com.twitter.common:stats:0.0.114, com.twitter:util-collection_2.11:6.27.0 (), com.twitter.common:util-sampler:0.0.77, com.twitter:twitter-server_2.11:1.13.0 (), com.twitter.common:metrics:0.0.37, com.twitter.common:collections:0.0.109, com.twitter.common:base:0.0.114, com.github.spullara.mustache.java:compiler:0.8.18, com.twitter.common:util:0.0.120, com.twitter.common:stats-util:0.0.58, com.twitter.common:application-action:0.0.89, com.twitter.finatra:finatra-utils_2.11:2.0.1 (), com.fasterxml.jackson.module:jackson-module-scala_2.11:2.4.4)
[info] Here are other libraries that were evicted:
[info]  * org.scala-lang:scala-reflect:2.11.2 -> 2.11.7 (caller: com.twitter.finatra:finatra-scalap-compiler-deps_2.11:2.0.0 (), com.fasterxml.jackson.module:jackson-module-scala_2.11:2.4.4)
[info]  * commons-lang:commons-lang:2.5 -> 2.6 (caller: com.twitter.common:quantity:0.0.98, net.sourceforge.wurfl:wurfl:1.6.2.1, com.twitter:finagle-httpx_2.11:6.28.0 (), com.twitter:finagle-http_2.11:6.28.0 (), com.williamhill.uwurfl:uwurfl_2.11:1.4-SNAPSHOT, com.twitter.common:util-executor-service-shutdown:0.0.66, com.twitter.common:stats:0.0.114, com.twitter.common:metrics:0.0.37, com.twitter.common:collections:0.0.109, com.twitter.common:base:0.0.114, com.twitter.common:util:0.0.120, org.apache.thrift:libthrift:0.5.0, com.twitter.common:stats-util:0.0.58, com.twitter.common:application-action:0.0.89)
[info]  * org.slf4j:slf4j-api:(1.6.1, 1.7.5, 1.5.8) -> 1.7.7 (caller: org.clapper:grizzled-slf4j_2.11:1.0.2, org.slf4j:jul-to-slf4j:1.7.7, org.slf4j:log4j-over-slf4j:1.7.7, net.sourceforge.wurfl:wurfl:1.6.2.1, org.apache.thrift:libthrift:0.5.0, ch.qos.logback:logback-classic:1.0.13, net.sf.ehcache:ehcache-core:2.4.3, org.slf4j:jcl-over-slf4j:1.7.7, io.dropwizard.metrics:metrics-core:3.1.0)
[info]  * joda-time:joda-time:2.2 -> 2.5 (caller: com.github.nscala-time:nscala-time_2.11:1.6.0, com.twitter.finatra:finatra-utils_2.11:2.0.1 (), com.twitter.inject:inject-core_2.11:2.0.1 (), com.fasterxml.jackson.datatype:jackson-datatype-joda:2.4.4)
[info]  * commons-io:commons-io:2.2 -> 2.4 (caller: commons-fileupload:commons-fileupload:1.3.1, com.twitter.finatra:finatra-utils_2.11:2.0.1 (), com.twitter.inject:inject-core_2.11:2.0.1 ())
[info]  * com.fasterxml.jackson.core:jackson-annotations:2.4.0 -> 2.4.4 (caller: com.fasterxml.jackson.core:jackson-databind:2.4.4, com.twitter.finatra:finatra-utils_2.11:2.0.1 (), com.twitter.inject:inject-core_2.11:2.0.1 (), com.fasterxml.jackson.datatype:jackson-datatype-joda:2.4.4, com.fasterxml.jackson.module:jackson-module-scala_2.11:2.4.4)
[info]  * javax.servlet:servlet-api:2.4 -> 2.5 (caller: com.twitter.finatra:finatra-http_2.11:2.0.1 (), net.sourceforge.wurfl:wurfl:1.6.2.1)
[info]  * org.scala-lang:scala-library:(2.11.4, 2.11.2, 2.11.0, 2.11.6) -> 2.11.7 (caller: com.twitter:util-registry_2.11:6.27.0 (), com.twitter:util-events_2.11:6.27.0 (), org.scala-lang.modules:scala-xml_2.11:1.0.5, com.twitter:util-hashing_2.11:6.27.0 (), com.twitter:finagle-http_2.11:6.28.0 (), com.twitter:finagle-zipkin_2.11:6.28.0 (), com.twitter.finatra:finatra-httpclient_2.11:2.0.1 (), com.twitter.inject:inject-core_2.11:2.0.1 (), com.twitter:finagle-stats_2.11:6.28.0 (), com.github.rlazoti:finagle-metrics_2.11:0.0.2, org.scala-lang:scala-reflect:2.11.2 (), com.twitter:twitter-server_2.11:1.13.0 (), org.clapper:grizzled-slf4j_2.11:1.0.2, com.twitter.inject:inject-app_2.11:2.0.1 (), com.twitter.finatra:finatra-slf4j_2.11:2.0.1 (), com.twitter:util-jvm_2.11:6.27.0 (), com.twitter:scrooge-core_2.11:4.0.0, com.twitter:util-app_2.11:6.27.0 (), com.twitter.finatra:finatra-jackson_2.11:2.0.1 (), com.twitter.finatra:finatra-utils_2.11:2.0.1 (), com.twitter.inject:inject-server_2.11:2.0.1 (), com.twitter:finagle-thrift_2.11:6.28.0 (), com.twitter:util-function_2.11:6.27.0 (), com.twitter:util-stats_2.11:6.27.0 (), com.twitter:finagle-core_2.11:6.28.0 (), com.twitter:finagle-httpx_2.11:6.28.0 (), com.twitter:util-core_2.11:6.27.0 (), com.github.nscala-time:nscala-time_2.11:1.6.0, com.twitter:util-codec_2.11:6.27.0 (), com.williamhill.uwurfl:uwurfl_2.11:1.4-SNAPSHOT, com.twitter:util-logging_2.11:6.27.0 (), com.twitter.inject:inject-modules_2.11:2.0.1 (), com.twitter:util-collection_2.11:6.27.0 (), com.twitter.finatra:finatra-http_2.11:2.0.1 (), com.twitter.inject:inject-request-scope_2.11:2.0.1 (), org.scala-lang:scala-reflect:2.11.7 (), org.scala-lang.modules:scala-parser-combinators_2.11:1.0.4, com.twitter:finagle-httpx-compat_2.11:6.28.0 (), com.fasterxml.jackson.module:jackson-module-scala_2.11:2.4.4, com.twitter.finatra:finatra-scalap-compiler-deps_2.11:2.0.0 ())
@scosenza

This comment has been minimized.

Contributor

scosenza commented Sep 24, 2015

If I downgrade the version of logback-classic to "0.9.28" in the hello-world example, I get the same error as you:

[info] Exception encountered when attempting to run a suite with class name: com.twitter.hello.HelloWorldFeatureTest *** ABORTED ***
[info]   java.lang.ClassCastException: com.twitter.finatra.logging.FinagleMDCAdapter cannot be cast to ch.qos.logback.classic.util.LogbackMDCAdapter

As such, it looks like you're getting the older version of logback on your classpath. Perhaps try excluding the older logback-classic from your wurlf dependencies e.g.

"net.sourceforge.wurfl" % "wurfl" % versions.wurflJava exclude("ch.qos.logback", "logback-classic")

@cacoco cacoco added the in triage label Oct 1, 2015

@cacoco cacoco closed this Nov 5, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment