失败 org.eclipse.jetty.annotations.ServletContainerInitializersStarter@59309333
FAILED org.eclipse.jetty.annotations.ServletContainerInitializersStarter@59309333
我正在开发使用 sbt、scalatra 构建的 Spark 应用程序,当我编译项目时,出现以下错误
$ my-spark-app git:(master) ✗ sbt
[info] Loading project definition from /home/limitless/Documents/projects/test/my-spark-app/project
[info] Updating {file:/home/limitless/Documents/projects/test/my-spark-app/project/}my-spark-app-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 1 Scala source to /home/limitless/Documents/projects/test/my-spark-app/project/target/scala-2.10/sbt-0.13/classes...
[info] Set current project to My Spark App Server (in build file:/home/limitless/Documents/projects/test/my-spark-app/)
> ~;jetty:stop;jetty:stop
[success] Total time: 0 s, completed Aug 31, 2017 4:43:47 PM
[success] Total time: 0 s, completed Aug 31, 2017 4:43:47 PM
1. Waiting for source changes... (press enter to interrupt)
> ~;jetty:stop;jetty:start
[success] Total time: 0 s, completed Aug 31, 2017 4:43:53 PM
[info] Updating {file:/home/limitless/Documents/projects/test/my-spark-app/}my-spark-app-server...
[info] Generating /home/limitless/Documents/projects/test/my-spark-app/target/scala-2.11/resource_managed/main/rebel.xml.
[info] Resolving org.scala-lang#scala-reflect;2.11.0 ...
[info] Done updating.
[info] Compiling Templates in Template Directory: /home/limitless/Documents/projects/test/my-spark-app/src/main/webapp/WEB-INF/templates
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[info] Compiling 5 Scala sources to /home/limitless/Documents/projects/test/my-spark-app/target/scala-2.11/classes...
[info] Packaging /home/limitless/Documents/projects/test/my-spark-app/target/scala-2.11/my-spark-app-server_2.11-0.1.0-SNAPSHOT.jar ...
[info] Done packaging.
[info] starting server ...
[success] Total time: 29 s, completed Aug 31, 2017 4:44:22 PM
1. Waiting for source changes... (press enter to interrupt)
2017-08-31 16:44:22.686:INFO::main: Logging initialized @106ms
2017-08-31 16:44:22.691:INFO:oejr.Runner:main: Runner
2017-08-31 16:44:22.766:INFO:oejs.Server:main: jetty-9.2.1.v20140609
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/limitless/Documents/projects/test/my-spark-app/target/webapp/WEB-INF/lib/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/limitless/Documents/projects/test/my-spark-app/target/webapp/WEB-INF/lib/logback-classic-1.1.5.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.Log4jLoggerFactory]
2017-08-31 16:44:31.657:WARN:oejuc.AbstractLifeCycle:main: FAILED org.eclipse.jetty.annotations.ServletContainerInitializersStarter@59309333: java.lang.NoClassDefFoundError: com/sun/jersey/spi/inject/InjectableProvider
java.lang.NoClassDefFoundError: com/sun/jersey/spi/inject/InjectableProvider
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access0(URLClassLoader.java:73)
at java.net.URLClassLoader.run(URLClassLoader.java:368)
at java.net.URLClassLoader.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
build.scala
import sbt._
import Keys._
import org.scalatra.sbt._
import org.scalatra.sbt.PluginKeys._
import com.earldouglas.xwp.JettyPlugin
import com.mojolly.scalate.ScalatePlugin._
import ScalateKeys._
object MySparkAppServerBuild extends Build {
val Organization = "com.learning"
val Name = "My Spark App Server"
val Version = "0.1.0-SNAPSHOT"
val ScalaVersion = "2.11.8"
val ScalatraVersion = "2.5.1"
val SparkVersion = "2.2.0"
lazy val project = Project (
"my-spark-app-server",
file("."),
settings = ScalatraPlugin.scalatraWithJRebel ++ scalateSettings ++ Seq(
organization := Organization,
name := Name,
version := Version,
scalaVersion := ScalaVersion,
resolvers += Classpaths.typesafeReleases,
resolvers += "Scalaz Bintray Repo" at "http://dl.bintray.com/scalaz/releases",
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
"junit" % "junit" % "4.12" % "test",
"org.scalatra" %% "scalatra" % ScalatraVersion,
"org.scalatra" %% "scalatra-scalate" % ScalatraVersion,
"org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
"ch.qos.logback" % "logback-classic" % "1.1.5" % "runtime",
"org.eclipse.jetty" % "jetty-webapp" % "9.2.15.v20160210" % "container",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
"org.apache.spark" %% "spark-core" % SparkVersion
),
scalateTemplateConfig in Compile <<= (sourceDirectory in Compile){ base =>
Seq(
TemplateConfig(
base / "webapp" / "WEB-INF" / "templates",
Seq.empty, /* default imports should be added here */
Seq(
Binding("context", "_root_.org.scalatra.scalate.ScalatraRenderContext", importMembers = true, isImplicit = true)
), /* add extra bindings here */
Some("templates")
)
)
}
)
).enablePlugins(JettyPlugin)
}
我在 build.scala 文件中添加了这个 "com.sun.jersey" % "jersey-bundle" % "1.19.2" 库,我的问题已解决
libraryDependencies ++= Seq(
"junit" % "junit" % "4.12" % "test",
"org.scalatra" %% "scalatra" % ScalatraVersion,
"org.scalatra" %% "scalatra-scalate" % ScalatraVersion,
"org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
"ch.qos.logback" % "logback-classic" % "1.1.5" % "runtime",
"org.eclipse.jetty" % "jetty-webapp" % "9.2.15.v20160210" % "container",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
"org.apache.spark" %% "spark-core" % SparkVersion,
"com.sun.jersey" % "jersey-bundle" % "1.19.2"
)
我正在开发使用 sbt、scalatra 构建的 Spark 应用程序,当我编译项目时,出现以下错误
$ my-spark-app git:(master) ✗ sbt
[info] Loading project definition from /home/limitless/Documents/projects/test/my-spark-app/project
[info] Updating {file:/home/limitless/Documents/projects/test/my-spark-app/project/}my-spark-app-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 1 Scala source to /home/limitless/Documents/projects/test/my-spark-app/project/target/scala-2.10/sbt-0.13/classes...
[info] Set current project to My Spark App Server (in build file:/home/limitless/Documents/projects/test/my-spark-app/)
> ~;jetty:stop;jetty:stop
[success] Total time: 0 s, completed Aug 31, 2017 4:43:47 PM
[success] Total time: 0 s, completed Aug 31, 2017 4:43:47 PM
1. Waiting for source changes... (press enter to interrupt)
> ~;jetty:stop;jetty:start
[success] Total time: 0 s, completed Aug 31, 2017 4:43:53 PM
[info] Updating {file:/home/limitless/Documents/projects/test/my-spark-app/}my-spark-app-server...
[info] Generating /home/limitless/Documents/projects/test/my-spark-app/target/scala-2.11/resource_managed/main/rebel.xml.
[info] Resolving org.scala-lang#scala-reflect;2.11.0 ...
[info] Done updating.
[info] Compiling Templates in Template Directory: /home/limitless/Documents/projects/test/my-spark-app/src/main/webapp/WEB-INF/templates
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[info] Compiling 5 Scala sources to /home/limitless/Documents/projects/test/my-spark-app/target/scala-2.11/classes...
[info] Packaging /home/limitless/Documents/projects/test/my-spark-app/target/scala-2.11/my-spark-app-server_2.11-0.1.0-SNAPSHOT.jar ...
[info] Done packaging.
[info] starting server ...
[success] Total time: 29 s, completed Aug 31, 2017 4:44:22 PM
1. Waiting for source changes... (press enter to interrupt)
2017-08-31 16:44:22.686:INFO::main: Logging initialized @106ms
2017-08-31 16:44:22.691:INFO:oejr.Runner:main: Runner
2017-08-31 16:44:22.766:INFO:oejs.Server:main: jetty-9.2.1.v20140609
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/limitless/Documents/projects/test/my-spark-app/target/webapp/WEB-INF/lib/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/limitless/Documents/projects/test/my-spark-app/target/webapp/WEB-INF/lib/logback-classic-1.1.5.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.Log4jLoggerFactory]
2017-08-31 16:44:31.657:WARN:oejuc.AbstractLifeCycle:main: FAILED org.eclipse.jetty.annotations.ServletContainerInitializersStarter@59309333: java.lang.NoClassDefFoundError: com/sun/jersey/spi/inject/InjectableProvider
java.lang.NoClassDefFoundError: com/sun/jersey/spi/inject/InjectableProvider
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access0(URLClassLoader.java:73)
at java.net.URLClassLoader.run(URLClassLoader.java:368)
at java.net.URLClassLoader.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
build.scala
import sbt._
import Keys._
import org.scalatra.sbt._
import org.scalatra.sbt.PluginKeys._
import com.earldouglas.xwp.JettyPlugin
import com.mojolly.scalate.ScalatePlugin._
import ScalateKeys._
object MySparkAppServerBuild extends Build {
val Organization = "com.learning"
val Name = "My Spark App Server"
val Version = "0.1.0-SNAPSHOT"
val ScalaVersion = "2.11.8"
val ScalatraVersion = "2.5.1"
val SparkVersion = "2.2.0"
lazy val project = Project (
"my-spark-app-server",
file("."),
settings = ScalatraPlugin.scalatraWithJRebel ++ scalateSettings ++ Seq(
organization := Organization,
name := Name,
version := Version,
scalaVersion := ScalaVersion,
resolvers += Classpaths.typesafeReleases,
resolvers += "Scalaz Bintray Repo" at "http://dl.bintray.com/scalaz/releases",
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
"junit" % "junit" % "4.12" % "test",
"org.scalatra" %% "scalatra" % ScalatraVersion,
"org.scalatra" %% "scalatra-scalate" % ScalatraVersion,
"org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
"ch.qos.logback" % "logback-classic" % "1.1.5" % "runtime",
"org.eclipse.jetty" % "jetty-webapp" % "9.2.15.v20160210" % "container",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
"org.apache.spark" %% "spark-core" % SparkVersion
),
scalateTemplateConfig in Compile <<= (sourceDirectory in Compile){ base =>
Seq(
TemplateConfig(
base / "webapp" / "WEB-INF" / "templates",
Seq.empty, /* default imports should be added here */
Seq(
Binding("context", "_root_.org.scalatra.scalate.ScalatraRenderContext", importMembers = true, isImplicit = true)
), /* add extra bindings here */
Some("templates")
)
)
}
)
).enablePlugins(JettyPlugin)
}
我在 build.scala 文件中添加了这个 "com.sun.jersey" % "jersey-bundle" % "1.19.2" 库,我的问题已解决
libraryDependencies ++= Seq(
"junit" % "junit" % "4.12" % "test",
"org.scalatra" %% "scalatra" % ScalatraVersion,
"org.scalatra" %% "scalatra-scalate" % ScalatraVersion,
"org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
"ch.qos.logback" % "logback-classic" % "1.1.5" % "runtime",
"org.eclipse.jetty" % "jetty-webapp" % "9.2.15.v20160210" % "container",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
"org.apache.spark" %% "spark-core" % SparkVersion,
"com.sun.jersey" % "jersey-bundle" % "1.19.2"
)