twitter / finagle

A fault tolerant, protocol-agnostic RPC system
https://twitter.github.io/finagle
Apache License 2.0
8.79k stars 1.46k forks source link

Error injecting constructor, java.lang.NoClassDefFoundError: com/twitter/finagle/http/Method$Get$ #634

Closed chenhj closed 7 years ago

chenhj commented 7 years ago
  jdk1.8 
  scala 2.11.11
  sbt 0.13.15

  I want to  use quill

"io.getquill" % "quill-finagle-mysql_2.11" % "1.3.0" "com.twitter" %% "finagle-mysql" % "6.45.0",

  But it depends on

"com.twitter"%"finagle-stats_2.11"%"6.45.0", "com.twitter"%"finagle-thrift_2.11"%"6.45.0", "com.twitter"%"finagle-zipkin_2.11"%"6.45.0", "com.twitter"%"finagle-http_2.11"%"6.35.0", "com.twitter" % "util-app_2.11" % "6.45.0", "com.twitter" % "twitter-server_2.11" % "1.30.0",

I started the service with an error

 The details are as follows

 build.sbt 

import sbt.Keys._

name := "finatra-demo"

version := "1.0"
scalaVersion := "2.11.11"
javaOptions ++= Seq(
  "-Dlog.service.output=/dev/stderr",
  "-Dlog.access.output=/dev/stderr")

resolvers ++= Seq(
  Resolver.sonatypeRepo("releases"),
  Resolver.jcenterRepo,
  "twitter " at "http://clojars.org/repo/"
  ,  "Twitter Maven" at "https://maven.twttr.com",
  "Finatra Repo" at "http://twitter.github.com/finatra",
  "jitpack" at "https://jitpack.io",
  "Sonatype OSS Releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2"
)

// assembly for packaging as single jar
assemblyMergeStrategy in assembly := {
  case "BUILD" => MergeStrategy.discard
  case other => MergeStrategy.defaultMergeStrategy(other)
}
assemblyJarName in assembly := s"${name.value}.jar"
lazy val versions = new {
  val finatra = "2.1.6"
  val logback = "1.1.6"
  val guice = "4.0"
  //val getquill = "0.5.0"
  val getquill = "1.3.0"
  val slick = "3.1.1"
  val hikaricp = "2.4.5"
  val slickJoda = "2.1.0"
  val mysqljdbc = "5.1.37"
  val jodaTime = "2.9.3"
  val jodaConvert = "1.8"
  var twitterAsync = "516e77a"
  val typesafeConfig = "1.3.0"
  val mockito = "1.9.5"
  val scalatest = "2.2.6"
}
libraryDependencies ++= Seq(
  "org.apache.thrift" % "libthrift" % "0.6.1",
  "com.twitter.common" % "metrics" % "0.0.39",
  "org.slf4j" % "slf4j-log4j12" % "1.7.16",
  "org.slf4j" % "slf4j-log4j12" % "1.7.16",
  "com.twitter" % "jsr166e" % "1.1.0",
  "io.getquill" % "quill-finagle-mysql_2.11" % "1.3.0",
   "com.twitter" %% "finagle-mysql" % "6.45.0",
    "com.twitter"%"finagle-stats_2.11"%"6.45.0",
    "com.twitter"%"finagle-thrift_2.11"%"6.45.0",
    "com.twitter"%"finagle-zipkin_2.11"%"6.45.0",
    "com.twitter"%"finagle-http_2.11"%"6.35.0",
    "com.twitter" % "util-app_2.11" % "6.45.0",
    "com.twitter" % "twitter-server_2.11" % "1.30.0",
  "com.google.inject" % "guice" % "4.1.0",
  // finatra
  "com.twitter.finatra" %% "finatra-http" % versions.finatra,
  "com.twitter.finatra" %% "finatra-slf4j" % versions.finatra,

  "joda-time" % "joda-time" % versions.jodaTime,
  "org.joda" % "joda-convert" % versions.jodaConvert,
  // scala async
  "org.scala-lang.modules" %% "scala-async" %  versions.async,
  // typesafe config
  "com.typesafe" % "config" % versions.typesafeConfig,
  "com.iheart" %% "ficus" % versions.ficus, // for scala friendly typesafe config
  // reflect
  "org.scala-lang" % "scala-reflect" % scalaVersion.value,
  // others
  "ch.qos.logback" % "logback-classic" % versions.logback
)
excludeDependencies ++=Seq(
  "org.slf4j" % "log4j-over-slf4j"
  ,"org.slf4j" % "slf4j-nop"
  ,"org.slf4j" % "slf4j-jdk14"
)
Revolver.settings

ExampleController.scala


  package com.twiiter.demo.controller

import com.google.inject.Singleton
import com.twitter.finagle.http.Request
import com.twitter.finatra.http.filters.CommonFilters
import com.twitter.finatra.http.routing.HttpRouter
import com.twitter.finatra.http.{ Controller, HttpServer }
/**
 * Created by hjun  chenhj on 2017/7/25.
 */
@Singleton
class ExampleController extends Controller {
  get("/") { request: Request =>
    "<h1>Hello, world!</h1>"
  }
}

object ExampleServer extends HttpServer {
  override def configureHttp(router: HttpRouter): Unit = {
    router
      .filter[CommonFilters]
      .add[ExampleController]
  }
}

reStart error


  inatra-demo[ERROR] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
finatra-demo[ERROR] SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
finatra-demo[ERROR] log4j:WARN No appenders could be found for logger (io.netty.util.internal.logging.InternalLoggerFactory).
finatra-demo[ERROR] log4j:WARN Please initialize the log4j system properly.
finatra-demo[ERROR] log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
finatra-demo[ERROR] 七月 25, 2017 6:49:05 下午 com.twitter.finagle.http.HttpMuxer$$anonfun$4 apply
finatra-demo[ERROR] 信息: HttpMuxer[/admin/metrics.json] = com.twitter.finagle.stats.MetricsExporter(<function1>)
finatra-demo[ERROR] 七月 25, 2017 6:49:05 下午 com.twitter.finagle.http.HttpMuxer$$anonfun$4 apply
finatra-demo[ERROR] 信息: HttpMuxer[/admin/per_host_metrics.json] = com.twitter.finagle.stats.HostMetricsExporter(<function1>)
finatra-demo[ERROR] I 0725 10:49:05.685 THREAD1:  => com.twitter.server.handler.AdminRedirectHandler
finatra-demo[ERROR] I 0725 10:49:05.686 THREAD1: /admin/server_info => com.twitter.finagle.Filter$$anon$1
finatra-demo[ERROR] I 0725 10:49:05.686 THREAD1: /admin => com.twitter.server.handler.SummaryHandler
finatra-demo[ERROR] I 0725 10:49:05.686 THREAD1: /admin/contention => com.twitter.finagle.Filter$$anon$1
finatra-demo[ERROR] I 0725 10:49:05.687 THREAD1: /admin/lint => com.twitter.server.handler.LintHandler
finatra-demo[ERROR] I 0725 10:49:05.687 THREAD1: /admin/lint.json => com.twitter.server.handler.LintHandler
finatra-demo[ERROR] I 0725 10:49:05.687 THREAD1: /admin/failedlint => com.twitter.server.handler.FailedLintRuleHandler
finatra-demo[ERROR] I 0725 10:49:05.687 THREAD1: /admin/threads => com.twitter.server.handler.ThreadsHandler
finatra-demo[ERROR] I 0725 10:49:05.687 THREAD1: /admin/threads.json => com.twitter.server.handler.ThreadsHandler
finatra-demo[ERROR] I 0725 10:49:05.687 THREAD1: /admin/announcer => com.twitter.finagle.Filter$$anon$1
finatra-demo[ERROR] I 0725 10:49:05.687 THREAD1: /admin/dtab => com.twitter.finagle.Filter$$anon$1
finatra-demo[ERROR] I 0725 10:49:05.687 THREAD1: /admin/pprof/heap => com.twitter.server.handler.HeapResourceHandler
finatra-demo[ERROR] I 0725 10:49:05.687 THREAD1: /admin/pprof/profile => com.twitter.server.handler.ProfileResourceHandler
finatra-demo[ERROR] I 0725 10:49:05.687 THREAD1: /admin/pprof/contention => com.twitter.server.handler.ProfileResourceHandler
finatra-demo[ERROR] I 0725 10:49:05.688 THREAD1: /admin/ping => com.twitter.server.handler.ReplyHandler
finatra-demo[ERROR] I 0725 10:49:05.688 THREAD1: /admin/shutdown => com.twitter.server.handler.ShutdownHandler
finatra-demo[ERROR] I 0725 10:49:05.688 THREAD1: /admin/tracing => com.twitter.server.handler.TracingHandler
finatra-demo[ERROR] I 0725 10:49:05.688 THREAD1: /admin/events => com.twitter.server.handler.EventsHandler
finatra-demo[ERROR] I 0725 10:49:05.688 THREAD1: /admin/events/record/ => com.twitter.server.handler.EventRecordingHandler

inatra-demo[ERROR] I 0725 10:49:05.702 THREAD1: Serving admin http on 0.0.0.0/0.0.0.0:9990
finatra-demo[ERROR] I 0725 10:49:05.981 THREAD1: Finagle version 6.45.0 (rev=fadc80cdd804f2885ebc213964542d5568a4f485) built at 20170609-103047
finatra-demo[ERROR] com.google.inject.ProvisionException: Unable to provision, see the following errors:
finatra-demo[ERROR] 
finatra-demo[ERROR] 1) Error injecting constructor, java.lang.NoClassDefFoundError: com/twitter/finagle/http/Method$Get$
finatra-demo[ERROR]   at com.twiiter.demo.controller.ExampleController.<init>(ExampleController.scala:12)
finatra-demo[ERROR]   at com.twiiter.demo.controller.ExampleController.class(ExampleController.scala:12)
finatra-demo[ERROR]   while locating com.twiiter.demo.controller.ExampleController
finatra-demo[ERROR] 
finatra-demo[ERROR] 1 error
finatra-demo[ERROR]     at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1028)
finatra-demo[ERROR]     at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1050)
finatra-demo[ERROR]     at com.twitter.inject.Injector.instance(Injector.scala:12)
finatra-demo[ERROR]     at com.twitter.finatra.http.routing.HttpRouter.add(HttpRouter.scala:121)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer$.configureHttp(ExampleController.scala:22)
finatra-demo[ERROR]     at com.twitter.finatra.http.HttpServer$class.postStartup(HttpServer.scala:34)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer$.postStartup(ExampleController.scala:18)
finatra-demo[ERROR]     at com.twitter.inject.app.App$class.main(App.scala:44)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer$.com$twitter$inject$server$TwitterServer$$super$main(ExampleController.scala:18)
finatra-demo[ERROR]     at com.twitter.inject.server.TwitterServer$class.main(TwitterServer.scala:72)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer$.main(ExampleController.scala:18)
finatra-demo[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
finatra-demo[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
finatra-demo[ERROR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
finatra-demo[ERROR]     at java.lang.reflect.Method.invoke(Method.java:498)
finatra-demo[ERROR]     at com.twitter.app.App$$anonfun$nonExitingMain$3.apply(App.scala:225)
finatra-demo[ERROR]     at com.twitter.app.App$$anonfun$nonExitingMain$3.apply(App.scala:224)
finatra-demo[ERROR]     at scala.Option.foreach(Option.scala:257)
finatra-demo[ERROR]     at com.twitter.app.App$class.nonExitingMain(App.scala:224)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer$.nonExitingMain(ExampleController.scala:18)
finatra-demo[ERROR]     at com.twitter.inject.server.TwitterServer$class.main(TwitterServer.scala:72)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer$.main(ExampleController.scala:18)
finatra-demo[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
finatra-demo[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
finatra-demo[ERROR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
finatra-demo[ERROR]     at java.lang.reflect.Method.invoke(Method.java:498)
finatra-demo[ERROR]     at com.twitter.app.App$$anonfun$nonExitingMain$3.apply(App.scala:225)
finatra-demo[ERROR]     at com.twitter.app.App$$anonfun$nonExitingMain$3.apply(App.scala:224)
finatra-demo[ERROR]     at scala.Option.foreach(Option.scala:257)
finatra-demo[ERROR]     at com.twitter.app.App$class.nonExitingMain(App.scala:224)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer$.nonExitingMain(ExampleController.scala:18)
finatra-demo[ERROR]     at com.twitter.app.App$class.main(App.scala:190)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer$.main(ExampleController.scala:18)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer.main(ExampleController.scala)
finatra-demo[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
finatra-demo[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
finatra-demo[ERROR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
finatra-demo[ERROR]     at java.lang.reflect.Method.invoke(Method.java:498)
finatra-demo[ERROR]     at scala.reflect.internal.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:70)
finatra-demo[ERROR]     at scala.reflect.internal.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
finatra-demo[ERROR]     at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:101)
finatra-demo[ERROR]     at scala.reflect.internal.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:70)

inatra-demo[ERROR]     at scala.reflect.internal.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:70)
finatra-demo[ERROR]     at scala.reflect.internal.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
finatra-demo[ERROR]     at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:101)
finatra-demo[ERROR]     at scala.reflect.internal.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:70)
finatra-demo[ERROR]     at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:101)
finatra-demo[ERROR]     at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:22)
finatra-demo[ERROR]     at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:39)
finatra-demo[ERROR]     at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:29)
finatra-demo[ERROR]     at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:39)
finatra-demo[ERROR]     at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:65)
finatra-demo[ERROR]     at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:87)
finatra-demo[ERROR]     at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:98)
finatra-demo[ERROR]     at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:103)
finatra-demo[ERROR]     at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
finatra-demo[ERROR] Caused by: java.lang.NoClassDefFoundError: com/twitter/finagle/http/Method$Get$
finatra-demo[ERROR]     at com.twitter.finatra.http.Controller.<init>(Controller.scala:7)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleController.<init>(ExampleController.scala:12)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleController$$FastClassByGuice$$f5bbf722.newInstance(<generated>)
finatra-demo[ERROR]     at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
finatra-demo[ERROR]     at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:111)
finatra-demo[ERROR]     at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:90)
finatra-demo[ERROR]     at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:268)
finatra-demo[ERROR]     at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
finatra-demo[ERROR]     at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
finatra-demo[ERROR]     at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
finatra-demo[ERROR]     at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:194)
vkostyukov commented 7 years ago

Can you try removing "com.twitter"%"finagle-http_2.11"%"6.35.0" from your build file?

chenhj commented 7 years ago

Thank @vkostyukov reply, I tried, and the same problem The details of the jar package are as follows


> dependencyList
[info] aopalliance:aopalliance:1.0
[info] ch.qos.logback:logback-classic:1.1.6
[info] ch.qos.logback:logback-core:1.1.6
[info] com.fasterxml.jackson.core:jackson-annotations:2.8.4
[info] com.fasterxml.jackson.core:jackson-core:2.8.4
[info] com.fasterxml.jackson.core:jackson-databind:2.8.4
[info] com.fasterxml.jackson.datatype:jackson-datatype-joda:2.4.4
[info] com.fasterxml.jackson.module:jackson-module-paranamer:2.8.4
[info] com.fasterxml.jackson.module:jackson-module-scala_2.11:2.8.4
[info] com.github.ben-manes.caffeine:caffeine:2.3.4
[info] com.github.nscala-time:nscala-time_2.11:1.6.0
[info] com.github.spullara.mustache.java:compiler:0.8.18
[info] com.google.code.findbugs:jsr305:2.0.1
[info] com.google.guava:guava:19.0
[info] com.google.inject:guice:4.1.0
[info] com.google.inject.extensions:guice-assistedinject:4.0
[info] com.google.inject.extensions:guice-multibindings:4.0
[info] com.iheart:ficus_2.11:1.2.3
[info] com.thoughtworks.paranamer:paranamer:2.8
[info] com.twitter:finagle-base-http_2.11:6.45.0
[info] com.twitter:finagle-core_2.11:6.45.0
[info] com.twitter:finagle-http2_2.11:6.45.0
[info] com.twitter:finagle-http_2.11:6.45.0
[info] com.twitter:finagle-mysql_2.11:6.45.0
[info] com.twitter:finagle-netty4-http_2.11:6.45.0
[info] com.twitter:finagle-netty4_2.11:6.45.0
[info] com.twitter:finagle-stats_2.11:6.45.0
[info] com.twitter:finagle-thrift_2.11:6.45.0
[info] com.twitter:finagle-toggle_2.11:6.45.0
[info] com.twitter:finagle-tunable_2.11:6.45.0
[info] com.twitter:finagle-zipkin-core_2.11:6.45.0
[info] com.twitter:finagle-zipkin_2.11:6.45.0
[info] com.twitter:jsr166e:1.1.0
[info] com.twitter:libthrift:0.5.0-7
[info] com.twitter:scrooge-core_2.11:4.18.0
[info] com.twitter:twitter-server_2.11:1.30.0
[info] com.twitter:util-app_2.11:6.45.0
[info] com.twitter:util-cache_2.11:6.45.0
[info] com.twitter:util-codec_2.11:6.45.0
[info] com.twitter:util-collection_2.11:6.45.0
[info] com.twitter:util-core_2.11:6.45.0
[info] com.twitter:util-events_2.11:6.45.0
[info] com.twitter:util-function_2.11:6.45.0
[info] com.twitter:util-hashing_2.11:6.45.0
[info] com.twitter:util-jvm_2.11:6.45.0
[info] com.twitter:util-lint_2.11:6.45.0
[info] com.twitter:util-logging_2.11:6.45.0
[info] com.twitter:util-registry_2.11:6.45.0
[info] com.twitter:util-security_2.11:6.45.0
[info] com.twitter:util-stats_2.11:6.45.0
[info] com.twitter:util-tunable_2.11:6.45.0
[info] com.twitter.common:base:0.0.116
[info] com.twitter.common:collections:0.0.111
[info] com.twitter.common:metrics:0.0.39
[info] com.twitter.common:quantity:0.0.100
[info] com.twitter.common:stats-util:0.0.60
[info] com.twitter.common:util-executor-service-shutdown:0.0.68
[info] com.twitter.common:util-system-mocks:0.0.105
[info] com.twitter.finatra:finatra-http_2.11:2.1.6
[info] com.twitter.finatra:finatra-jackson_2.11:2.1.6
[info] com.twitter.finatra:finatra-scalap-compiler-deps_2.11:2.0.0
[info] com.twitter.finatra:finatra-slf4j_2.11:2.1.6
[info] com.twitter.finatra:finatra-utils_2.11:2.1.6
[info] com.twitter.inject:inject-app_2.11:2.1.6
[info] com.twitter.inject:inject-core_2.11:2.1.6
[info] com.twitter.inject:inject-modules_2.11:2.1.6
[info] com.twitter.inject:inject-request-scope_2.11:2.1.6
[info] com.twitter.inject:inject-server_2.11:2.1.6
[info] com.twitter.inject:inject-utils_2.11:2.1.6
[info] com.typesafe:config:1.3.1
[info] com.typesafe.scala-logging:scala-logging_2.11:3.5.0
[info] commons-codec:commons-codec:1.3
[info] commons-fileupload:commons-fileupload:1.3.1
[info] commons-io:commons-io:2.4
[info] commons-lang:commons-lang:2.6
[info] commons-logging:commons-logging:1.1.1
[info] default:finatra-demo_2.11:1.0
[info] io.getquill:quill-core_2.11:1.3.0
[info] io.getquill:quill-finagle-mysql_2.11:1.3.0
[info] io.getquill:quill-sql_2.11:1.3.0
[info] io.netty:netty:3.10.1.Final
[info] io.netty:netty-buffer:4.1.10.Final
[info] io.netty:netty-codec:4.1.10.Final
[info] io.netty:netty-codec-http:4.1.10.Final
[info] io.netty:netty-codec-http2:4.1.10.Final
[info] io.netty:netty-codec-socks:4.1.10.Final
[info] io.netty:netty-common:4.1.10.Final
[info] io.netty:netty-handler:4.1.10.Final
[info] io.netty:netty-handler-proxy:4.1.10.Final
[info] io.netty:netty-resolver:4.1.10.Final
[info] io.netty:netty-transport:4.1.10.Final
[info] io.netty:netty-transport-native-epoll:4.1.10.Final
[info] javax.inject:javax.inject:1
[info] javax.servlet:servlet-api:2.5
[info] joda-time:joda-time:2.9.3
[info] junit:junit:4.4
[info] log4j:log4j:1.2.17
[info] net.codingwell:scala-guice_2.11:4.0.0
[info] org.apache.httpcomponents:httpclient:4.0.1
[info] org.apache.httpcomponents:httpcore:4.0.1
[info] org.apache.thrift:libthrift:0.6.1
[info] org.clapper:grizzled-slf4j_2.11:1.0.2
[info] org.joda:joda-convert:1.8
[info] org.scala-lang:scala-reflect:2.11.11
[info] org.scala-lang:scalap:2.11.11
[info] org.scala-lang.modules:scala-async_2.11:0.9.5
[info] org.scala-lang.modules:scala-parser-combinators_2.11:1.0.4
[info] org.scalamacros:resetallattrs_2.11:1.0.0
[info] org.slf4j:jcl-over-slf4j:1.7.7
[info] org.slf4j:jul-to-slf4j:1.7.7
[info] org.slf4j:slf4j-api:1.7.21
[info] org.slf4j:slf4j-log4j12:1.7.16

reStart fail


finatra-demo[ERROR] I 0726 02:10:59.201 THREAD1: Finagle version 6.45.0 (rev=fadc80cdd804f2885ebc213964542d5568a4f485) built at 20170609-103047
finatra-demo[ERROR] com.google.inject.ProvisionException: Unable to provision, see the following errors:
finatra-demo[ERROR] 
finatra-demo[ERROR] 1) Error injecting constructor, java.lang.NoClassDefFoundError: com/twitter/finagle/http/Method$Get$
finatra-demo[ERROR]   at com.twiiter.demo.controller.ExampleController.<init>(ExampleController.scala:12)
finatra-demo[ERROR]   at com.twiiter.demo.controller.ExampleController.class(ExampleController.scala:12)
finatra-demo[ERROR]   while locating com.twiiter.demo.controller.ExampleController
finatra-demo[ERROR] 
finatra-demo[ERROR] 1 error
finatra-demo[ERROR]     at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1028)
finatra-demo[ERROR]     at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1050)
finatra-demo[ERROR]     at com.twitter.inject.Injector.instance(Injector.scala:12)
finatra-demo[ERROR]     at com.twitter.finatra.http.routing.HttpRouter.add(HttpRouter.scala:121)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer$.configureHttp(ExampleController.scala:22)
finatra-demo[ERROR]     at com.twitter.finatra.http.HttpServer$class.postStartup(HttpServer.scala:34)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer$.postStartup(ExampleController.scala:18)
finatra-demo[ERROR]     at com.twitter.inject.app.App$class.main(App.scala:44)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer$.com$twitter$inject$server$TwitterServer$$super$main(ExampleController.scala:18)
finatra-demo[ERROR]     at com.twitter.inject.server.TwitterServer$class.main(TwitterServer.scala:72)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer$.main(ExampleController.scala:18)
finatra-demo[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
finatra-demo[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
finatra-demo[ERROR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
finatra-demo[ERROR]     at java.lang.reflect.Method.invoke(Method.java:498)
finatra-demo[ERROR]     at com.twitter.app.App$$anonfun$nonExitingMain$3.apply(App.scala:225)
finatra-demo[ERROR]     at com.twitter.app.App$$anonfun$nonExitingMain$3.apply(App.scala:224)
finatra-demo[ERROR]     at scala.Option.foreach(Option.scala:257)
finatra-demo[ERROR]     at com.twitter.app.App$class.nonExitingMain(App.scala:224)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer$.nonExitingMain(ExampleController.scala:18)
finatra-demo[ERROR]     at com.twitter.app.App$class.main(App.scala:190)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer$.main(ExampleController.scala:18)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleServer.main(ExampleController.scala)
finatra-demo[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
finatra-demo[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
finatra-demo[ERROR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
finatra-demo[ERROR]     at java.lang.reflect.Method.invoke(Method.java:498)
finatra-demo[ERROR]     at scala.reflect.internal.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:70)
finatra-demo[ERROR]     at scala.reflect.internal.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
finatra-demo[ERROR]     at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:101)
finatra-demo[ERROR]     at scala.reflect.internal.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:70)
finatra-demo[ERROR]     at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:101)
finatra-demo[ERROR]     at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:22)
finatra-demo[ERROR]     at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:39)
finatra-demo[ERROR]     at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:29)
finatra-demo[ERROR]     at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:39)
finatra-demo[ERROR]     at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:65)
finatra-demo[ERROR]     at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:87)
finatra-demo[ERROR]     at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:98)
finatra-demo[ERROR]     at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:103)
finatra-demo[ERROR]     at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
finatra-demo[ERROR] Caused by: java.lang.NoClassDefFoundError: com/twitter/finagle/http/Method$Get$
finatra-demo[ERROR]     at com.twitter.finatra.http.Controller.<init>(Controller.scala:7)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleController.<init>(ExampleController.scala:12)
finatra-demo[ERROR]     at com.twiiter.demo.controller.ExampleController$$FastClassByGuice$$f5bbf722.newInstance(<generated>)
finatra-demo[ERROR]     at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
finatra-demo[ERROR]     at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:111)
finatra-demo[ERROR]     at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:90)
finatra-demo[ERROR]     at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:268)
finatra-demo[ERROR]     at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
finatra-demo[ERROR]     at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
finatra-demo[ERROR]     at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
finatra-demo[ERROR]     at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:194)
finatra-demo[ERROR]     at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
finatra-demo[ERROR]     at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1019)
finatra-demo[ERROR]     at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1085)
finatra-demo[ERROR]     at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1015)
finatra-demo[ERROR]     ... 40 more
finatra-demo[ERROR] Caused by: java.lang.ClassNotFoundException: com.twitter.finagle.http.Method$Get$
finatra-demo[ERROR]     at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
finatra-demo[ERROR]     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
finatra-demo[ERROR]     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
finatra-demo[ERROR]     ... 55 more
finatra-demo[ERROR] Exception thrown in main on startup
finatra-demo ... finished with exit code 1

> 
jcrossley commented 7 years ago

Hey @chenhj ! I see you're missing a comma after the quill import:

"com.twitter" % "jsr166e" % "1.1.0", "io.getquill" % "quill-finagle-mysql_2.11" % "1.3.0" "com.twitter" %% "finagle-mysql" % "6.45.0",

chenhj commented 7 years ago

@jcrossley Thank you for your reply. I am missing a comma on the information above. But this is not the real cause of the problem. My project can be compiled normally, but it has been started and an error has occurred,

mosesn commented 7 years ago

@chenhj NoClassDefFound means that there's a class that your code needs, but it can't find it. This typically happens when your project transitively depends on more than one version of a library. For example, imagine that you're building project A, which depends on lib X, and project B, which also depends on lib X. However, project B was built against an older version of lib X, which used to have a class, but which it no longer exports.

A => B => X (version 1) A => X (version 2)

Then when it runs, A makes a call into B, which tries to make a call into X, but because the project now uses the newer version instead of the older version, it can't find the class it needs.

I would encourage you to use sbt-dependency-graph to see which versions of finagle you're depending on transitively, and ensure that every library you use uses the same version of finagle-http.

This isn't a finagle-specific problem, and you may find it with other libraries like guava or scalactic in the future. I'm going to close this ticket, but please feel free to reach out if you have other concerns.