5 Replies Latest reply on Sep 16, 2002 2:17 PM by mipe

    Creating HttpContext using jetty-web.xml, is it possible?

      hi,

      I'd like to have a http context that refers to an external directory to my .war.
      I can do it by configuring Jetty in jboss admin, and I read the same effect can be reached by hacking jetty-plugin.sar/META-INF/jboss-service.xml and put some xml lines into the Configure element that calls addContext(), but it would be nice that my web application could set everything it needs and no extra hacks would have to be made by the deployer.

      So I'm trying to write a jetty-web.xml with little success because I don't exactly know what the class attribute means in the Configure element. I tried this:


      /updates/*
      /tmp/
      TRUE



      but an exception is thrown when deploying (IllegalArgumentException: not of type class org.mortbay.jetty.Server)

      How can I access Jetty server and force to add new http context? Is there any way to do this that affects my web application only?

      Regards
      -peter

        • 1. Re: Creating HttpContext using jetty-web.xml, is it possible

          I can't imagine that nobody met this problem.
          Is it possible to call Jetty methods from a bean or with jetty-web.xml? If it is, how can I do that?

          • 2. Re: Creating HttpContext using jetty-web.xml, is it possible

            Jetty XML is a very thin layer which introspects directly on and calls the underlying Java objects.

            in your jboss-service.xml the context of the call is a org.mortbay.jetty.Server.

            in a WEB-INF/jetty-web.xml it is a org.jboss.jetty.JBossWebApplicationContext - since you are configuring a single webapp - not the whole server.

            You will need the javadoc to see exactly what methods are available on each class. Once you get the idea, you can do pretty much anything you like with this scheme - it's just the learning curve is a little steep at the beginning.

            Jules

            • 3. Re: Creating HttpContext using jetty-web.xml, is it possible

              Thank you very much, Jules!

              I share my solution to help those people who also encounter this problem. Here you are:

              a jetty-web.xml in a WEB-INF directory creates a new HttpContext when deploying the webapp:




              /uc/updates/*
              /home/peter/tmp/uc/updates/
              TRUE





              I still don't know how to ident source with whitespaces not to be removed by the forum. Sorry for that.

              • 4. Re: Creating HttpContext using jetty-web.xml, is it possible

                Nice !

                So effectively, you are binding an external root to static content, into a virtual root within your webapp/dynamic-content.. ?

                Jules

                • 5. Re: Creating HttpContext using jetty-web.xml, is it possible

                  yes exactly. I have a folder, which can vary in each deployment, containing updates. I need to reach it via http to make the clients be able to download the updates. that is why I wanted to bind this directory to a http context.

                  -peter