6 Replies Latest reply on Feb 23, 2009 12:42 PM by Carlos Oliva

    Serving Static Content JBoss5.0.0.GA

    Carlos Oliva Novice

      Is there a way to serve static ontent with JBoss5.0.0.GA? I used to add a Context element in the server.xml file of JBoss4.X and that was sufficient to server static content. In JBoss5.0.0.GA, I just get errors when I try to add a context element on the server.xml. It appears that the context cannoit be found as a child of the host element.
      Thw wiki just have examples for JBoss 4.x but lacks an examole for JBoss5.x

        • 2. Re: Serving Static Content JBoss5.0.0.GA
          Carlos Oliva Novice

          Do you know how to use the DefaultServlet to render static content? If I understand clearly, in JBoss 5.x, one cannot add a Context element to the Host element anywhere. Researching the wiki, I found somebody that mentioned the use of the DefaultServlet to serve static content but the explanation is somewhat thrifty.

          Another possibility is to copy the static content to the ROOT.war folder.

          • 3. Re: Serving Static Content JBoss5.0.0.GA
            Peter Johnson Master

            You could try the suggestion in my last post in the topic I linked to - add another deploy directory. That would seem to be the easiest way that is closest to what the Context entry used to provide.

            • 4. Re: Serving Static Content JBoss5.0.0.GA
              Carlos Oliva Novice

              A couple of questions:
              1) Where is the profile-service.xml file? I cannot find it
              2) Would this replace the current deploy folder or jsut add another?
              It would be difficult to replace it because I would need to re-work all the procedures that I have designed for the developers and the QA department

              • 5. Re: Serving Static Content JBoss5.0.0.GA
                Peter Johnson Master

                Darn, that was an old post and they renamed the file, and I didn't double-check the name. Sorry. Look in conf/bootstrap/profile-repository.xml. You want to add a new entry to the applicationURIs property of the SerializableDeploymentRepositoryFactory bean.

                As I mentioned, you need to place the static content into a directory that has a .war suffix and the directory you use for applicationURIs must be the parent of that directory. Assume this is your static content:


                Then set applicationURIs as follows:

                <property name="applicationURIs">
                 <array elementClass="java.net.URI">

                In addition, you will want these files:


                The web.xml can be empty:


                The jboss-web.xml can set the root context:


                Then also remove the ROOT.war from the deploy directory (it also uses '/' as the context and you cant have two wab apps wit the same root context).

                Now you should be able to access you static content as, for example http://localhost:8080/some.css

                • 6. Re: Serving Static Content JBoss5.0.0.GA
                  Carlos Oliva Novice

                  Thank you PeterJ. I will try this option and try to decide between this solution and just copying the folder witht he static content into the ROOT context. I now have acouple of laterntaives to try.
                  The solution that you describe proabbly allows greater flexibility and I will have to weigh the extra functionality against redoing the established protocols of the team. Thank you again.

                  PS: I hope that JBoss 5.0.1.GA will let us define static context with greater ease; without having to al ter the profile. Perhaps, such flexibility can be added to the deployers folder.