Setting a root context for JBoss-Jetty

This may seem like a trivial entry to some, but I had a terrible time figuring out how to get the Jetty integrated JBoss distribution to look like your standard webserver. It took me so much time, I promised myself I would publish directions to make it easier for others.

A) JBoss-Jetty runs on port 80
B) JBoss-Jetty has a root context (the base application for the website, such as http://dmartin.org).

A) wasn't hard to figure out.

  • Edit <jboss-home>\server\default\deploy\jbossweb.sar\META-INF\jboss-service.xml
  • Find the line <Set name="Port"><SystemProperty name="jetty.port" default="8080"/></Set>
  • Change "8080" to "80", and voila.

B) is pretty easy, but finding documentation for it took me days of searching (and I'm a professional researcher - aka a glorified web searcher). There is only one place that I could find that has it documented, the JBoss-Jetty FAQ obscurely found in the JBoss CVS.

  • First, you need a default webapp that's going to be this root context. Easy enough, just create a folder "<jboss-home>\server\default\deploy\default.war" (The name default.war could be anything).
  • Now create a "WEB-INF\" folder inside the "default.war\" folder.
  • Inside "WEB-INF\" create a file called "jboss-web.xml".
  • Make the contents of "jboss-web.xml":

    <?xml version="1.0" encoding="UTF-8"?>
    <jboss-web>
    <context-root>/</context-root>
    <jboss-web>

  • Restart JBoss-Jetty, and you should have a root context.

One last thing you'll probably want to do is create a web.xml inside "default.war\WEB-INF\" that includes (at a bare minimum) a welcome file list, so that your index.html or index.jsp becomes your homepage.

Hopefully this saves someone from the difficulty I went through finding out how to use JBoss-Jetty as your every day web server.

  1. Anonymous (not verified)
    Wed, 03/11/2009 - 2:27pm
    Thank you for posting this! I was pulling my hair out and this fixed it for me
  2. Anonymous (not verified)
    Tue, 02/02/2010 - 8:50pm
    Thank you soooo much! For plain Jetty is slightly different but conceptually is similar. I added the jetty-web.xml into my WEB-INF and it worked. <?xml version="1.0" encoding="UTF-8" ?> /mycontext