views:

43

answers:

1

Hi, all.

I am trying to configure a Jetty (6.x) WebAppContext with a custom subclass of WebAppClassLoader. In code (Scala), it's simply this:

  val context = new WebAppContext()
  val cwacl = new CustomWebAppClassLoader(context)
  context.setClassLoader(cwacl)
  ...

This works fine when embedding Jetty. In production, however, I just deploy a war file to a stand-alone jetty instance, so there's no opportunity to configure things in code like this.

I can't figure out how to do the same thing via Jetty's configuration files. Any help is appreciated.

Bonus: How would you configure maven-jetty-plugin to use the CustomWebAppClassLoader :)

+1  A: 

You could use the context config files. There are examples in the contexts/ directory.

This would be something along these lines:

<Configure id="mycontext1" class="org.mortbay.jetty.webapp.WebAppContext">
    <Set name="classLoader">
        <New class="f.q.n.CustomWebAppClassLoader">
           <Arg><Ref id="mycontext1"/></Arg></New>
    </Set>
</Configure>

(See the Jetty XML Syntax configuration reference for more details.)

Bruno
Thanks, Bruno! This seemed to do the trick.
overthink