SBT,Jetty和Servlet 3.0

时间:2012-03-27 12:39:09

标签: servlets jetty sbt

我有一个非常小的问题。

我有以下build.sbt文件:

name := "Tueet"

libraryDependencies += "org.eclipse.jetty" % "jetty-webapp" % "8.1.2.v20120308"

在调用sbt update之后,我得到以下内容:

[info] Set current project to Tueet (in build file:/C:/dev/tueet/)
[info] Updating {file:/C:/dev/tueet/}default-d5e982...
[info] Resolving org.scala-lang#scala-library;2.9.1 ...
[info] Resolving org.eclipse.jetty#jetty-webapp;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty#jetty-xml;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty#jetty-util;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty#jetty-servlet;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty#jetty-security;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty#jetty-server;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016 ...
[info] Resolving org.eclipse.jetty#jetty-continuation;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty#jetty-http;8.1.2.v20120308 ...
[info] Resolving org.eclipse.jetty#jetty-io;8.1.2.v20120308 ...
[warn]  [NOT FOUND  ] org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit (603ms)
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/org/eclipse/jetty/orbit/javax.servlet/3.0.0.v201112011016/javax.servlet-3.0.0.v201112011016.orbit
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::              FAILED DOWNLOADS            ::
[warn]  :: ^ see resolution messages for details  ^ ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[error] {file:/C:/dev/tueet/}default-d5e982/*:update: sbt.ResolveException: download     failed: org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit
[error] Total time: 1 s, completed 2012-03-27 14:33:34

这很愚蠢,因为它在Maven中无效。我发现这是因为Orbit用包装做了一些事情(他们明确地将它设置为轨道)。

我尝试做了排除(“org.eclipse.jetty.orbit”,“javax.servlet”)但没有发生任何事情,它仍然需要这种依赖。

我找不到任何关于如何实际解决此问题的信息,也许有人会在这里帮助我:)

更新:提供的错误提供了一种解决方法,因此为了解决此问题,我实际上将build.sbt更改为

name := "Tueet"

libraryDependencies += "org.eclipse.jetty" % "jetty-server" % "8.1.2.v20120308"

ivyXML := 
<dependency org="org.eclipse.jetty.orbit" name="javax.servlet" rev="3.0.0.v201112011016">
<artifact name="javax.servlet" type="orbit" ext="jar"/>
</dependency>

3 个答案:

答案 0 :(得分:8)

请参阅此错误:https://jira.codehaus.org/browse/JETTY-1493

问题的症结在于常春藤不支持轨道延伸,需要将轨道包装类型映射到jar。不确定你是否使用常春藤,但根本原因是相同的,你可以看到它是从maven中心下载的网址。

这个错误比我们首先切换到这些依赖项的原因还要多一些。

https://bugs.eclipse.org/bugs/show_bug.cgi?id=371954

答案 1 :(得分:6)

我找到了解决方法。更多信息可以在这里找到:SBT, Jetty and Servlet 3.0

classpathTypes ~= (_ + "orbit")

libraryDependencies ++= Seq(
  "org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container"         artifacts (Artifact("javax.servlet", "jar", "jar")
  )
)

libraryDependencies ++= Seq(
  "org.eclipse.jetty" % "jetty-webapp" % "8.1.4.v20120524" % "container" artifacts            (Artifact("jetty-webapp", "jar", "jar"))
)

答案 2 :(得分:1)

使用sbt 0.12+(来自:https://github.com/sbt/sbt/issues/499

libraryDependencies ++= Seq(
    "org.eclipse.jetty" % "jetty-webapp" % "8.1.7.v20120910" % "container",
    "org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container" artifacts Artifact("javax.servlet", "jar", "jar")
)