2011-10-04 92 views
2

我試圖用xsbt-web-plugin使用SBT。 其次在項目網站上的說明,但繼續得到以下(對於長度抱歉)sbt,碼頭和類路徑

sbt.JettyRunException: Jetty and its dependencies must be on the jetty classpath 
    at sbt.JettyRunner.runError(WebApp.scala:72) 
    at sbt.JettyRunner.apply(WebApp.scala:62) 
    at com.github.siasia.WebPlugin$.jettyRunAction(WebPlugin.scala:129) 
    at com.github.siasia.WebPlugin$$anonfun$jettyRunAction$1.apply(WebPlugin.scala:133) 
    at com.github.siasia.WebPlugin$$anonfun$jettyRunAction$1.apply(WebPlugin.scala:133) 
    at com.github.siasia.WebPlugin$.withCurrentRef(WebPlugin.scala:138) 
    at com.github.siasia.WebPlugin$.jettyRunAction(WebPlugin.scala:133) 
    at com.github.siasia.WebPlugin$$anonfun$10.apply(WebPlugin.scala:141) 
    at com.github.siasia.WebPlugin$$anonfun$10.apply(WebPlugin.scala:141) 
    at sbt.Command$$anonfun$command$1$$anonfun$apply$1.apply(Command.scala:33) 
    at sbt.Command$$anonfun$command$1$$anonfun$apply$1.apply(Command.scala:33) 
    at sbt.Command$.process(Command.scala:91) 
    at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(Main.scala:86) 
    at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(Main.scala:86) 
    at sbt.State$$anon$1.process(State.scala:60) 
    at sbt.MainLoop$$anonfun$next$1.apply(Main.scala:86) 
    at sbt.MainLoop$$anonfun$next$1.apply(Main.scala:86) 
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:13) 
    at sbt.MainLoop$.next(Main.scala:86) 
    at sbt.MainLoop$.run(Main.scala:81) 
    at sbt.MainLoop$$anonfun$runLogged$1.apply(Main.scala:75) 
    at sbt.MainLoop$$anonfun$runLogged$1.apply(Main.scala:72) 
    at sbt.Using.apply(Using.scala:25) 
    at sbt.MainLoop$.runLogged(Main.scala:72) 
    at sbt.MainLoop$.runLogged(Main.scala:62) 
    at sbt.xMain.run(Main.scala:33) 
    at xsbt.boot.Launch$.run(Launch.scala:54) 
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:43) 
    at xsbt.boot.Launch$.launch(Launch.scala:68) 
    at xsbt.boot.Launch$.apply(Launch.scala:14) 
    at xsbt.boot.Boot$.runImpl(Boot.scala:24) 
    at xsbt.boot.Boot$.main(Boot.scala:15) 
    at xsbt.boot.Boot.main(Boot.scala) 
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jetty/webapp/WebAppClassLoader 
    at java.lang.Class.forName0(Native Method) 
    at java.lang.Class.forName(Class.java:247) 
    at sbt.ModuleUtilities$.getObject(ModuleUtilities.scala:10) 
    at sbt.JettyRunner.createRunner$1(WebApp.scala:45) 
    at sbt.JettyRunner.runJetty$1(WebApp.scala:47) 
    at sbt.JettyRunner.apply(WebApp.scala:57) 
    at com.github.siasia.WebPlugin$.jettyRunAction(WebPlugin.scala:129) 
    at com.github.siasia.WebPlugin$$anonfun$jettyRunAction$1.apply(WebPlugin.scala:133) 
    at com.github.siasia.WebPlugin$$anonfun$jettyRunAction$1.apply(WebPlugin.scala:133) 
    at com.github.siasia.WebPlugin$.withCurrentRef(WebPlugin.scala:138) 
    at com.github.siasia.WebPlugin$.jettyRunAction(WebPlugin.scala:133) 
    at com.github.siasia.WebPlugin$$anonfun$10.apply(WebPlugin.scala:141) 
    at com.github.siasia.WebPlugin$$anonfun$10.apply(WebPlugin.scala:141) 
    at sbt.Command$$anonfun$command$1$$anonfun$apply$1.apply(Command.scala:33) 
    at sbt.Command$$anonfun$command$1$$anonfun$apply$1.apply(Command.scala:33) 
    at sbt.Command$.process(Command.scala:91) 
    at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(Main.scala:86) 
    at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(Main.scala:86) 
    at sbt.State$$anon$1.process(State.scala:60) 
    at sbt.MainLoop$$anonfun$next$1.apply(Main.scala:86) 
    at sbt.MainLoop$$anonfun$next$1.apply(Main.scala:86) 
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:13) 
    at sbt.MainLoop$.next(Main.scala:86) 
    at sbt.MainLoop$.run(Main.scala:81) 
    at sbt.MainLoop$$anonfun$runLogged$1.apply(Main.scala:75) 
    at sbt.MainLoop$$anonfun$runLogged$1.apply(Main.scala:72) 
    at sbt.Using.apply(Using.scala:25) 
    at sbt.MainLoop$.runLogged(Main.scala:72) 
    at sbt.MainLoop$.runLogged(Main.scala:62) 
    at sbt.xMain.run(Main.scala:33) 
    at xsbt.boot.Launch$.run(Launch.scala:54) 
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:43) 
    at xsbt.boot.Launch$.launch(Launch.scala:68) 
    at xsbt.boot.Launch$.apply(Launch.scala:14) 
    at xsbt.boot.Boot$.runImpl(Boot.scala:24) 
    at xsbt.boot.Boot$.main(Boot.scala:15) 
    at xsbt.boot.Boot.main(Boot.scala) 
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.webapp.WebAppClassLoader 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247) 
    at sbt.classpath.DualLoader.loadClass(DualLoader.scala:29) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247) 
    at sbt.classpath.LazyFrameworkLoader.doLoadClass(ClassLoaders.scala:122) 
    at sbt.classpath.LoaderBase.loadClass(ClassLoaders.scala:21) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247) 
    at java.lang.Class.forName0(Native Method) 
    at java.lang.Class.forName(Class.java:247) 
    at sbt.ModuleUtilities$.getObject(ModuleUtilities.scala:10) 
    at sbt.JettyRunner.createRunner$1(WebApp.scala:45) 
    at sbt.JettyRunner.runJetty$1(WebApp.scala:47) 
    at sbt.JettyRunner.apply(WebApp.scala:57) 
    at com.github.siasia.WebPlugin$.jettyRunAction(WebPlugin.scala:129) 
    at com.github.siasia.WebPlugin$$anonfun$jettyRunAction$1.apply(WebPlugin.scala:133) 
    at com.github.siasia.WebPlugin$$anonfun$jettyRunAction$1.apply(WebPlugin.scala:133) 
    at com.github.siasia.WebPlugin$.withCurrentRef(WebPlugin.scala:138) 
    at com.github.siasia.WebPlugin$.jettyRunAction(WebPlugin.scala:133) 
    at com.github.siasia.WebPlugin$$anonfun$10.apply(WebPlugin.scala:141) 
    at com.github.siasia.WebPlugin$$anonfun$10.apply(WebPlugin.scala:141) 
    at sbt.Command$$anonfun$command$1$$anonfun$apply$1.apply(Command.scala:33) 
    at sbt.Command$$anonfun$command$1$$anonfun$apply$1.apply(Command.scala:33) 
    at sbt.Command$.process(Command.scala:91) 
    at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(Main.scala:86) 
    at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(Main.scala:86) 
    at sbt.State$$anon$1.process(State.scala:60) 
    at sbt.MainLoop$$anonfun$next$1.apply(Main.scala:86) 
    at sbt.MainLoop$$anonfun$next$1.apply(Main.scala:86) 
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:13) 
    at sbt.MainLoop$.next(Main.scala:86) 
    at sbt.MainLoop$.run(Main.scala:81) 
    at sbt.MainLoop$$anonfun$runLogged$1.apply(Main.scala:75) 
    at sbt.MainLoop$$anonfun$runLogged$1.apply(Main.scala:72) 
    at sbt.Using.apply(Using.scala:25) 
    at sbt.MainLoop$.runLogged(Main.scala:72) 
    at sbt.MainLoop$.runLogged(Main.scala:62) 
    at sbt.xMain.run(Main.scala:33) 
    at xsbt.boot.Launch$.run(Launch.scala:54) 
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:43) 
    at xsbt.boot.Launch$.launch(Launch.scala:68) 
    at xsbt.boot.Launch$.apply(Launch.scala:14) 
    at xsbt.boot.Boot$.runImpl(Boot.scala:24) 
    at xsbt.boot.Boot$.main(Boot.scala:15) 
    at xsbt.boot.Boot.main(Boot.scala) 
[error] sbt.JettyRunException: Jetty and its dependencies must be on the jetty classpath 
[error] Use 'last' for the full log. 

這裏是我的配置: 在項目/ plugins.sbt:

resolvers += "Web plugin repo" at "http://siasia.github.com/maven2"  

addSbtPlugin("com.github.siasia" %% "xsbt-web-plugin" % "0.1.2") 

libraryDependencies += "org.eclipse.jetty" % "jetty-server" % "8.0.1.v20110908" 

這裏是我的版本。 sbt:

name := "Project Manager" 

scalaVersion := "2.9.1" 

resolvers += "repo.codahale.com" at "http://repo.codahale.com" 

libraryDependencies ++= Seq(
    "org.scalatra" %% "scalatra" % "2.0.1", 
    "org.scalatra" %% "scalatra-scalate" % "2.0.1", 
    "javax.servlet" % "servlet-api" % "2.4", 
    "org.slf4j" % "slf4j-simple" % "1.6.2", 
    "postgresql" % "postgresql" % "9.0-801.jdbc4", 
    "com.codahale" % "jerkson_2.9.1" % "0.4.2", 
    "org.eclipse.jetty" % "jetty-server" % "8.0.1.v20110908" 
) 

seq(webSettings :_*) 

任何幫助將不勝感激!

+1

也許你需要包括jetty? val jettyServer =「org.eclipse.jetty」%「jetty-server」%「8.0.1.v20110908」 – schmmd

+0

添加此依賴關係會產生相同的錯誤 –

+0

我也切換到使用基本配置 –

回答

3

看起來插件的作者錯過了在文檔的Usage部分中添加Jetty依賴項。但是,如果你在Running Lift看,你會看到,碼頭是一個需要外部的依賴:

libraryDependencies ++= Seq(
    "net.liftweb" %% "lift-webkit" % "2.3" % "compile", 
    "org.mortbay.jetty" % "jetty" % "6.1.22" % "jetty", 
    "ch.qos.logback" % "logback-classic" % "0.9.26" 
) 
+0

將依賴項添加到項目依賴項產生同樣的錯誤。 –

0

這個問題實際上涉及到碼頭必須依賴和碼頭8事實並非但支持。

最終的配置是這樣的:

name := "Project Manager" 

scalaVersion := "2.9.1" 

resolvers += "repo.codahale.com" at "http://repo.codahale.com" 

libraryDependencies ++= Seq(
    "org.scalatra" %% "scalatra" % "2.0.1", 
    "org.scalatra" %% "scalatra-scalate" % "2.0.1", 
    "javax.servlet" % "servlet-api" % "2.4", 
    "org.slf4j" % "slf4j-simple" % "1.6.2", 
    "postgresql" % "postgresql" % "9.0-801.jdbc4", 
    "com.codahale" % "jerkson_2.9.1" % "0.4.2", 
    "org.eclipse.jetty" % "jetty-webapp" % "7.3.0.v20110203" % "jetty" // For Jetty 7 
) 

seq(webSettings :_*) 

感謝您的幫助。

0

嘗試將所有lib和main類複製到jar/war的根目錄,並將classpath設置爲lib/*。確保lib包含所有的碼頭罐。這對我有效=>

java -cp myway;「lib/*」mainpackage.main