10 Replies Latest reply on Jan 24, 2007 7:08 AM by brianr

    where to put context.xml in JBoss?

    weipingy

      Hi;

      I have an web application with the instructions to install on a standalone tomcat 5.0.28. With the standalone installation, we need to place a file called context.xml (context is the name of the context root) under conf/catalina/localhost.

      Please advise where I should put that file under a JBoss 4.0.1SP1 (w/ embeded tomcat 5.0.28) environment.

      Thanks in advance

        • 1. Re: where to put context.xml in JBoss?
          brian.stansberry

          Not sure if support for reading a context.xml was in 4.0.1SP1 or not, but if it was it will look for the file in your war's WEB-INF folder. This is different from standalone tomcat, which looks in META-INF. There's a JIRA issue to also support META-INF.

          • 2. Re: where to put context.xml in JBoss?
            mpollard

            Hi,

            I have the same problem. The context.xml (in our case myservice.xml) uses a docbase to point to the war on the file system. The war is not dropped into jboss/tomcat.

            For example the myservice.xml contains the following:

            Context debug="0" docBase="c:/mysoftwaretool/mywebapp.war" path="/myapp" reloadable="true"

            Loader checkInterval="3" classname="org.apache.catalina.loader.StandardLoader"

            Context


            So where should the myservice.xml (context.xml) go in this case in JBoss4.0.3 sp1.

            Thanks:)
            Michelle



            • 3. Re: where to put context.xml in JBoss?
              brian.stansberry

              AFAIK, deploying a war by simply deploying a context.xml is not supported.

              You can configure JBoss to scan external directories for deployment; look at the server/.../conf/jboss-service.xml file, DeploymentScanner MBean, URLs attribute.

              • 4. Re: where to put context.xml in JBoss?

                I also wanted to expose some static pages and do it with separate context.xml files. It's a nice way to do it. Unfortunately the one way which seems to work on both JBoss and Tomcat is to alter the "server.xml" file (in the $TOMCAT_HOME/conf diretory on Tomcat or in the $JBOSS_HOME/server/default/deploy/jbossweb-tomcat55.sar directory on JBoss).

                Not really sure what the "deployOnStartup" being false is all about, because it deploys it (I mean I can see my files available at http://localhost:8080/somejokes).

                 <Host name="localhost"
                 autoDeploy="false" deployOnStartup="false" deployXML="false">
                
                 <Alias>www.agreatdomain.com</Alias>
                 <Alias>mypcnamefornatsnearme</Alias>
                
                 <!-- [ MCB 20060401 Supposed to be able to do these with ${TOMCAT_HOME}/jboss.web/localhost/*.xml". "jboss-web" is the "Engine" name above.
                 ] -->
                 <Context
                 path="/somejokes"
                 docBase="l:/download/new/jokes"
                 override="true"
                 />
                


                • 5. Re: where to put context.xml in JBoss?
                  astronox

                  I do not know about Tomcat 5.0.x, but I know for Tomcat 5.5.x you can place your application specific context.xml file in your WAR's WEB-INF directory. Tomcat will read and parse that file. Note that not all of the configuration parameters present in Tomcat's original specification of the context.xml file will work, because they are superseded by JBoss' configuration. One such parameter is the context path; you can set it in the jboss-web.xml file.

                  • 6. Re: where to put context.xml in JBoss?
                    mpollard

                    Hi All,

                    Thanks for the swift replies. Given the application uses docbase= I went with adding the context elements to the server.xml.

                    Works perfect. Thanks for all the help and suggestions.

                    cheers,
                    Michelle

                    • 7. Re: where to put context.xml in JBoss?
                      dplass

                      I also discovered (the hard way) that it only works if you put it in WEB-INF.

                      However, I wanted to add a "Resources" tag (as defined in http://tomcat.apache.org/tomcat-5.5-doc/config/resources.html), referencing a class in the .war. But this doesn't work, beause the war is not deployed yet! What is the recommended place to put the class file(s) that are needed *at* deployment time? (BTW, it ain't jboss/lib!)

                      • 8. Re: where to put context.xml in JBoss?
                        anil.saldhana

                        No need to discover the hard way, when you refer to the wiki page for Tomcat on the JBoss wiki:
                        http://wiki.jboss.org/wiki/Wiki.jsp?page=Tomcat

                        And in this wiki page, you would have stumbled upon a wiki page for the context.xml:
                        Using context.xml in JBoss web applications
                        http://wiki.jboss.org/wiki/Wiki.jsp?page=UsingContextDotXML

                        • 9. Re: where to put context.xml in JBoss?
                          dplass

                           

                          "anil.saldhana@jboss.com" wrote:
                          No need to discover the hard way, when you refer to the wiki page for Tomcat on the JBoss wiki:
                          http://wiki.jboss.org/wiki/Wiki.jsp?page=Tomcat

                          And in this wiki page, you would have stumbled upon a wiki page for the context.xml:
                          Using context.xml in JBoss web applications
                          http://wiki.jboss.org/wiki/Wiki.jsp?page=UsingContextDotXML


                          My question still remains: how do I get the Context/Resources tag to properly load a class that is defined only in the war that is (about to be) deployed?

                          • 10. Re: where to put context.xml in JBoss?
                            brianr

                            In addition to the WEB-INF/context.xml file or the META-INF/context.xml file, standalone Tomcat will also look for an application's context information in its "conf/Catalina/localhost&lt;or-other-hostname&gt;/" direcotry, in a file named &lt;context-name&gt;.xml. For instance, if I have a web application called "myApp", then in standalone Tomcat, I can keep its context information in "conf/Catalina/localhost/myApp.xml".

                            This is very convenient for deployments of a single WAR file to multiple environments (development testing, QA, production) since we are able to specify environment-specific information in the external context file without having to go in and rewrite the context information in the WAR file. Deployment/redeployment becomes a simple matter of copying a WAR file to either the development, QA, or production server.

                            Why does JBoss not seem to support these externalized context files, even though it incorporates Tomcat 5.5 which does support them? If it supports them, where should the "myApp.xml" context file be placed such that JBoss can find it?