SBT, Jetty and Servlet 3.0 #499

Closed
hrj opened this Issue Jul 6, 2012 · 21 comments

Comments

Projects
None yet

hrj commented Jul 6, 2012

The issue is well describe here:
http://stackoverflow.com/questions/9889674/sbt-jetty-and-servlet-3-0

To summarize:

Adding,

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

to a project causes this:

[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

The root of the problem is desribed in this bug:
https://jira.codehaus.org/browse/JETTY-1493

The recommended fix:

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

has no effect for me. I even tried:

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

Still no luck. I have also tried

rm -r ~/.ivy2/cache/org.eclipse.jetty*
rm ~/.ivy2/cache/*.properties
rm ~/.ivy2/cache/*.xml

Still, no luck.

harrah closed this in 5a93605 Jul 6, 2012

Owner

harrah commented Jul 6, 2012

Yes, the abuse of <packaging> is unfortunate. For the workaround, in addition to the explicit artifact, you need to indicate that you want that type on the classpath:

classpathTypes += "orbit"

Also, you don't need the XML if you don't want it. The artifacts method on ModuleID can be used here. See also #463, and this thread: https://groups.google.com/forum/#!topic/simple-build-tool/AYLw15EJcvg

hrj commented Jul 6, 2012

Thanks Mark for the quick response.

Sorry for being a little dense, but can I use the workarounds with sbt 0.11.3 or do I have to use a version with your referenced commit?

I tried the following with sbt 0.11.3 to no avail:

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

That may be because I was not able to successfully do this:

classpathTypes += "orbit"

The error was:

build.sbt:22: error: No implicit for Append.Value[Set[String], java.lang.String] found,
  so java.lang.String cannot be appended to Set[String]
classpathTypes += "orbit"

Is that supported in 0.11.3 ?

Owner

harrah commented Jul 6, 2012

Sorry, that must have been added in 0.12. In 0.11, make the addition explicit:

classpathTypes <<= classpathTypes.apply {
  (ct: Set[String]) => ct + "orbit"
}

or the shorter version:

classpathTypes ~= (_ + "orbit")

hrj commented Jul 6, 2012

Thanks; that was accepted by sbt 0.11.3. But the result is still the same.

Can you please try this yourself? A very simple build file reproduces this error:
https://gist.github.com/3062255

Owner

harrah commented Jul 6, 2012

The artifacts method overrides the artifacts defined in the metadata (pom.xml), so it goes on the dependency being modified. Here, that dependency is 'javax.servlet' and not 'jetty-webapp'.

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

mheese commented Jul 11, 2012

Jesus, thanks a lot guys! Anyway, even though everything is written in the comments, it took me hours to solve it... if someone like me is searching for the exact lines, here you go:

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"))
)
Owner

harrah commented Jul 12, 2012

I expect you don't need the first setting. It is only required if you declare the artifact to have type "orbit" like in the original post (only "jar" is used here). The third setting probably doesn't need 'artifacts' because that should be the default artifact for jetty-webapp already.

right, this seems to work

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

the only problem i still have now is the classes form the javax.servlet package don't seem to be on the classpath, so i cannot compile code depending on these. i'd have expected the javax.servlet dependency to be in "provided" instead of "container" - but that just leads to a slightly different error message:

[info] downloading http://repo1.maven.org/maven2/org/eclipse/jetty/orbit/javax.servlet/3.0.0.v201112011016/javax.servlet-3.0.0.v201112011016.jar ...
[info]  [SUCCESSFUL ] org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.jar (660ms)
[warn]  [NOT FOUND  ] org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit (0ms)

what am i doing wrong?

arosien commented Aug 13, 2012

projects depending on a project with this workaround also need to do the workaround, it does not pass along the chain :(

oolekk commented Sep 4, 2012 edited by xuwei-k

didn't work for me on sbt 0.12. any clue why?

[warn]  [NOT FOUND  ] org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit (203ms)
[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]  ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run last *:update for the full output.
[error](*:update) sbt.ResolveException: download failed: org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit

oolekk commented Sep 17, 2012 edited by xuwei-k

this worked for me:

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

thx to Marko

zvozin commented Sep 23, 2012

To confirm, this works in SBT 0.12.0:

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

For me, using the version 8.1.0.v20120127 solved this problem.

E.g.: "org.eclipse.jetty" % "jetty-webapp" % "8.1.0.v20120127" % "test, container".

Owner

harrah commented Jul 31, 2013

Note that this issue is fixed in sbt 0.12.2 and later. The older jetty version probably works because it was before the metadata change. Newer versions of jetty should be usable in sbt versions before 0.12.2 with the workaround in #499 (comment).

ldeck commented Aug 4, 2013 edited by xuwei-k

@harrah it seems the work around is still necessary in sbt 0.12.4

libraryDependencies += 
"org.eclipse.jetty"        % "jetty-webapp"   % "8.1.12.v20130726" % "container"
[warn]  [NOT FOUND  ] org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit (78ms)
[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]  ::::::::::::::::::::::::::::::::::::::::::::::
Owner

harrah commented Aug 4, 2013

@ldeck If sbt <0.12.2 was used to get this dependency, the bad metadata in the cache won't be invalidated. Try removing ~/.ivy2/cache/org.eclipse.jetty.orbit and reresolving.

n8han commented Nov 4, 2013

I'm running into this problem when using the 0.13.0 launcher to resolve an app artifact that, transitively, depends on the dreaded "orbit" artifact from this launchconfig. Doesn't seem like the fix to sbt applies to its launcher.

Any ideas?

@n8han n8han added a commit to foundweekends/pamflet that referenced this issue Nov 4, 2013

@n8han n8han use netty for preview server since jetty servlet dependency can't be
resolved by launcher.

sbt/sbt#499 (comment)
71f542c
Owner

harrah commented Nov 4, 2013

You're right, it doesn't apply to the launcher. The complicated workarounds required for issues like this don't get applied to the launcher for various reasons. You can open a separate bug or a bug for unifying the sbt-side Ivy support with the launcher's. Honestly, I'm not sure either of those will happen anytime soon. If the issue is fixed by upgrading to the latest Ivy, it might be covered by #847.

If you can describe how to see the issue with the launchconfig (is it just a resolve error or is it a later linkage error or something?) I'll see if there is a workaround in your case.

n8han commented Nov 4, 2013

I found a workaround: foundweekends/pamflet@71f542c

:)

Owner

harrah commented Nov 4, 2013

Ok, great. Sorry for the trouble.

behrad commented Oct 12, 2014

Can someone elaborate on this?
hawtio/hawtio#122 (comment)

muuki88 referenced this issue in sbt/sbt-native-packager Jun 24, 2017

Open

Cross build with sbt 1.0 #1000

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