Jonathan Hendler
Jonathan Hendler

Reputation: 1259

xsbt 0.10.x using xsbt-web-plugin fails to find org.eclipse.jetty during build

This used to work with sbt 0.7 using a web plugin.

I'm only trying to compile a servlet, but a standalone embedded jetty would be fine as well.

value eclipse is not a member of package org [error] import

_root_.org.eclipse.jetty.websocket.{ WebSocket , WebSocketServlet }

Note that root was added because it fixed a similar error with sbt 0.7.x getting lost in a conflicting packaged path.

in my build.sbt I have (only need distribution probably)

libraryDependencies ++= Seq (
    "org.eclipse.jetty" % "jetty-distribution" % "7.4.5.v20110725" % "jetty"
    , "org.eclipse.jetty" % "jetty-webapp" % "7.4.5.v20110725" % "jetty"
    , "org.eclipse.jetty" % "jetty-http" % "7.4.5.v20110725" % "jetty"
    , "org.eclipse.jetty" % "jetty-server" % "7.4.5.v20110725" % "jetty"
    , "org.eclipse.jetty" % "jetty-io" % "7.4.5.v20110725" % "jetty"
    , "org.eclipse.jetty" % "jetty-util" % "7.4.5.v20110725" % "jetty"
    , "org.eclipse.jetty" % "jetty-websocket" % "7.4.5.v20110725" % "jetty"
    , "org.eclipse.jetty" % "jetty-continuation" % "7.4.5.v20110725" % "jetty"
)

The file that fails to compile has

package org.example

import _root_.javax.servlet.http._
import _root_.org.eclipse.jetty.websocket.{  WebSocket  , WebSocketServlet }

...

class Home extends WebSocketServlet { 

...

[edit] - removed directory structure info

Upvotes: 0

Views: 458

Answers (1)

Mark Harrah
Mark Harrah

Reputation: 7019

Dependencies in the jetty configuration are only used to run Jetty itself and are not put on the classpath for compilation. For the Jetty libraries to be available on the compilation classpath, use either the compile or provided configuration. compile puts the libraries on all classpaths, while provided only puts them on the compile (and test) classpath.

In this case, you probably want provided,jetty. This makes the Jetty jars available to the web plugin for running Jetty (the jetty part) as well as putting Jetty on your compilation classpath (the provided part).

For example, the websocket dependency would look like:

"org.eclipse.jetty" % "jetty-websocket" % "7.4.5.v20110725" % "provided,jetty"

Upvotes: 3

Related Questions