Jetty dependency setup in 0.5.4

13 views
Skip to first unread message

Kristian Domagala

unread,
Sep 16, 2009, 9:53:48 PM9/16/09
to simple-build-tool
Hi,

I'm fairly new to sbt and I like what I've seen so far, but I've come
across the following problem when I upgraded to version 0.5.4 to get
around issue 35 <http://code.google.com/p/simple-build-tool/issues/
detail?id=35>.

When I try to run jetty from sbt now, it has problems picking up the
managed Jetty dependencies and I get a message saying that I need to
add Jetty to the test classpath. When I revert back to 0.5.2, jetty-
run works as normal.

Has anything changed with how I should configure the project, or is it
really just a case of now having to add the Jetty jars to the test
classpath?


My project file looks like this:

import sbt._
class MyProject(info:ProjectInfo) extends DefaultWebProject(info) {
val jetty6 = "org.mortbay.jetty" % "jetty-ajp" % "6.1.14"
override def webappPath = "web"
override def jettyWebappPath = webappPath
override def scanDirectories = mainCompilePath ::
testCompilePath :: Nil
}

The relevant versions in my build.properties file are:
sbt.version=0.5.4
scala.version=2.7.5

I am running Java 1.5.0_19 on Mac OSX 10.5.8

This is the error I get when I try to run jetty from the sbt prompt:
> jetty-run
[info]
[info] == compile ==
[info] Source analysis: 0 new/modified, 0 indirectly invalidated, 0
removed.
[info] Compiling main sources...
[info] Nothing to compile.
[info] Post-analysis: 131 classes.
[info] == compile ==
[info]
[info] == copy-resources ==
[info] == copy-resources ==
[info]
[info] == prepare-webapp ==
[info] == prepare-webapp ==
[info]
[info] == jetty-run ==
java.lang.NoClassDefFoundError: org/mortbay/log/Logger
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at sbt.ModuleUtilities$.getObject(ModuleUtilities.scala:10)
at sbt.JettyRunner.runJetty$1(WebApp.scala:37)
....
[info] == jetty-run ==
[error] Error running jetty-run: Jetty and its dependencies must be on
the test classpath: java.lang.NoClassDefFoundError: org/mortbay/log/
Logger
[info]


Cheers,
Kristian.

Mark Harrah

unread,
Sep 17, 2009, 8:10:47 AM9/17/09
to simple-b...@googlegroups.com
Hi Kristian,

On 9/16/09, Kristian Domagala <kristian...@gmail.com> wrote:
>
> Hi,
>
> I'm fairly new to sbt and I like what I've seen so far, but I've come
> across the following problem when I upgraded to version 0.5.4 to get
> around issue 35 <http://code.google.com/p/simple-build-tool/issues/
> detail?id=35>.
>
> When I try to run jetty from sbt now, it has problems picking up the
> managed Jetty dependencies and I get a message saying that I need to
> add Jetty to the test classpath. When I revert back to 0.5.2, jetty-
> run works as normal.
>
> Has anything changed with how I should configure the project, or is it
> really just a case of now having to add the Jetty jars to the test
> classpath?

I thought the fix for #35 was backwards compatible, but on
reinspection it does require jetty to be on the test classpath and not
the compile classpath:

val jetty6 = "org.mortbay.jetty" % "jetty-ajp" % "6.1.14" % "test->default"

If this works for you, let me know and I'll update the documentation.

The issue was that the class loader used to load jetty itself must not
be able to find any classes from the project (or else you get #35).
So, this class loader uses only those jars in 'provided' and 'test'
that are not in 'compile'. Obviously not compatible, sorry about
that.

Thanks,
Mark

Kristian Domagala

unread,
Sep 18, 2009, 12:23:52 AM9/18/09
to simple-b...@googlegroups.com
Hi Mark,

Yes, that fixes the problem.

Thanks,
Kristian.

Jeremy

unread,
Sep 18, 2009, 6:48:30 AM9/18/09
to simple-build-tool
What about the situation (which I have run into), where your project
depends upon jetty at compile time also? You can't put jetty in the
"compile->default" configuration, because then you get the "Jetty and
its dependencies must be on the test classpath" error with jetty-run,
but you can put it in the "test->default" configuration because then
your main sources don't compile.

Thanks.

On Sep 17, 8:10 am, Mark Harrah <dmhar...@gmail.com> wrote:
> Hi Kristian,
>

Mark Harrah

unread,
Sep 18, 2009, 7:56:09 AM9/18/09
to simple-b...@googlegroups.com
First, you can always fall back to explicitly specifying the jetty jars
with 'jettyClasspath' and specifying the jars for the web application
with 'jettyRunClasspath'. 'jettyClasspath' cannot contain application jars
or else #35 occurs.

The 'provided' configuration is included at compile time and can also be a
place to put jetty, although 'provided' is probably not suitable for most
cases.

The other solution I considered was using a separate 'jetty' configuration and
loading the jars from there. Then, you could also have jetty in your compile
configuration. This had no compatibility at all, so I didn't go for that,
but perhaps it could be checked first before 'test' - 'compile'.

-Mark
Reply all
Reply to author
Forward
0 new messages