3 Replies Latest reply on Jan 28, 2009 4:56 AM by brettcave

    configuring custom error pages across all vhosts

    brettcave

      I would like to set up custom error pages across all vhosts on a JBoss
      AS. I have configured web.xml in ROOT.war of jboss-web.deployer with
      error-page / error-code / location directives for all errors -
      "/error/404.html" for not found as an example.

      I currently have the following setup on jboss:
      The standard vhost
      1 x name-based vhost (vhosts configured in server.xml)
      custom error pages on ROOT.war/error and configured
      ROOT.war/WEB-INF/web.xml for custom error pages.
      1 x app deployed on /myapp/ to name-based vhost

      What is needed to configure the custom error pages on the named virtual host?

      my server.xml looks similar to

       <Engine name="jboss.web" defaultHost="localhost">
       <Realm className="org.jboss.web.tomcat.security.JBossSecurityMgrRealm"
       certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
       allRolesMode="authOnly"
       />
       <Host name="localhost"
       autoDeploy="false" deployOnStartup="false" deployXML="false"
       configClass="org.jboss.web.tomcat.security.config.JBossContextConfig"
       >
       <Valve
      className="org.jboss.web.tomcat.service.jca.CachedConnectionValve"
      
      cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager"
      
      transactionManagerObjectName="jboss:service=TransactionManager" />
       </Host>
      
       <Host name="myvhost"
       autoDeploy="false" deployOnStartup="false"
      
      configClass="org.jboss.web.tomcat.security.config.JBossContextConfig">
       <Alias>vhost.access.uri</Alias>
       <Valve
      className="org.apache.catalina.valves.AccessLogValve"
      prefix="someprefix-" suffix=".log"
       pattern="common" directory="/path/to/log/" />
       <DefaultContext cookies="true" crossContext="true"
      override="true"/>
       </Host>
       </Engine>
      

      I'm guessing I need a valve that uses errorReportValve to get this right?

        • 1. Re: configuring custom error pages across all vhosts
          jaikiran

          Maybe i am missing something, but isn't the error page mapping in the web.xml independent of virtual hosts? What i mean is as long as you configure your web.xml correctly to map the error codes to custom error pages, it does not matter whether you have virtual host configured for the application. Maybe i am wrong. Could you please post the contents of your web.xml? And does the custom error page redirection, currently work without any additional changes.

          • 2. Re: configuring custom error pages across all vhosts
            brettcave

            Here is some testing I have done.

            There are 3 ways to access the application server:
            1) named vhost which is actually an apache server with mod_jk (http://vhost/). /myapp/*, /anotherapp/* and *.jsp are jkMounted.
            2) default vhost via apache and mod_jk (http://nonvhost/)
            3) direct to jboss (http://jboss:8080/) on default vhost.

            the names I have used in brackets are for reference purposes in this post.

            I have 3 contexts that I access:
            A) Default context, with no app deployed to it besides the default jboss-web.deployer (i.e. ROOT.war).
            B) myapp-ear.ear is deployed to context /myapp/ (context-root="myapp") and to the named vhost
            C) anotherapp is deployed to context /anotherapp/ on the default vhost (no vhost specification in jboss-web.xml)

            web.xml for jboss-web.deployer has the following:
            <error-page>
            <error-code>404</error-code>
            /error/404.html
            </error-page>

            None of the web.xml files for app B) and C) have any error directives in them.

            The results are as follows:

            1) + A) http://vhost/nopage.jsp - custom error page
            1) + B) http://vhost/myapp/nopage - default error
            1) + C) http://vhost/anotherapp/nopage - blank page

            2) + A) http://novhost/nopage.jsp - custom
            2) + B) http://novhost/myapp/nopage - custom
            2) + C) http://novhost/anotherapp/nopage - default

            3) + A) http://jboss/nopage.jsp - custom
            3) + B) http://jboss/myapp/nopage - custom
            3) + C) http://jboss/anotherapp/nopage - default


            why is 1) + C) giving a blank page?
            how do i get 1) + B) and 2) + C) and 3) + C) to give custom without modifying web.xml? or do i need to modify web.xml on those?

            my custom error page is set to /error/404.html and i have /error/404.html in ROOT.war

            • 3. Re: configuring custom error pages across all vhosts
              brettcave

              its not vhost specific, it seems to be context specific.

              Is there a way to set error-page location to a different context / absolute url?

              e.g. i want to deploy my error pages to context-root of /error
              and then in /myapp/ specify that error-page location is /error/error.jsp
              but using /error/error.jsp loads /myapp/error/error.jsp, rather than the absolute path.