1 Reply Latest reply on Nov 13, 2013 9:34 AM by Jens Augustsson

    migrating a tomcat application to JBoss 7.1.1 - problems with context.xml

    luca gioppo Novice

      I've got an application that works on tomcat and uses this context.xml configuration:


      <Context debug="0" reloadable="false" crossContext="false">

          <Parameter name="cfgFile" value="config.txt"

              override="false" />

          <Parameter name="pollutantFile" value="pollutant.csv"

              override="false" />

          <ResourceLink name="jdbc/srqa" global="jdbc/srqa"

              type="javax.sql.DataSource" />




      The parameters are used in this piece of code:


      ServletContext sc = getServletContext();

              String cfgFileName = sc.getInitParameter("cfgFile");


      Now I need to port this app in JBoss 7.1.1 and have created a custom module to enable the application to read external files as for:

      How to put an external file in the classpath

      Now the problem is that apparently JBoss ignores the context.xml file


      Where can I place the two parameters so that I can read them?

      Also the ResourceLink will become ... what? I expect that also that will be a problem.


        • 1. Re: migrating a tomcat application to JBoss 7.1.1 - problems with context.xml
          Jens Augustsson Newbie

          Hi luca,


          If you don't need access to this file outside the WAR, you might move the init-params to the standard descriptor file web.xml.


              <servlet-name>My Servlet</servlet-name> 
                  <description>This is an init parameter example</description>  

          More details found here.


          If you need access outside the WAR, here a link to another thread for those who need a replacement to context.xml outside the WAR


          Tomcat's ResourceLink links a global JNDI name to module (WAR) JNDI name. You won't be able to lookup global resources using local JNDI names inside your components unless you've made this mapping. So if it's ok for you to move it to the standard descriptor file web.xml, here's a snippet that might cut it for you:



          However, in your specific case you're trying to lookup a datasource and if you've configure it the "normal" way (using CLI or Web Console) and follow best practices, your datasource will be located in the jboss namespace in JNDI. So the lookup-name is more likely to be



          In general, the JBoss jboss-web.xml is the replacement file for context.xml. But you should prefer to use the standard web.xml descriptor file whenever possible.