From Plex-XML
Jump to: navigation, search
The context.xml is telling your servlet engine
  • where the application can be found
  • which database connections it has
  • how the application should be started and run

  • The context.xml -file should be copied into the folder <tomcathome>/conf/Catalina/localhost.
  • It has to be renamed as <name_of_your_application>.xml
  • The name of the datasource has to be: 'jdbc/....'

Example for Tomcat >= 5.5

The context.xml for Tomcat 5.5 or later needs a different structure than earlier versions. Any entry inside the <ResourceParms> tags have to be set as attributes within the <Resource> tag.
 <?xml version="1.0" encoding="UTF-8" ?> 
 <Context path="/LogMan" reloadable="false" privileged="false" debug="0">
  <Logger className="org.apache.catalina.logger.SystemOutLogger" verbosity="2" /> 
  <Resource name="jdbc/AS400" type="javax.sql.DataSource" maxWait="15000" maxActive="100" password="the_password"   
    url="jdbc:as400://;date format=iso;naming=system;libraries=,LM_SECURE,PRD_ACTDTA" 
    driverClassName="" maxIdle="30" username="actobjown" validationQuery="SELECT
    COUNT(*) FROM S2SOFTF" /> 
  <Resource name="jdbc/Account" type="javax.sql.DataSource" maxWait="15000" maxActive="10" maxIdle="30"
    password="the_acc_password" username="acc_transfer_prod"
    driverClassName="oracle.jdbc.OracleDriver" validationQuery="SELECT COUNT(*) FROM NAME_OF_YOUR_TABLE" /> 

What is this?
  • Plex-XML can use a validation query in the context.xml like: validationQuery="SELECT COUNT(*) FROM NAME_OF_YOUR_TABLE"
    • SQL query that can be used to validate connections before they are returned to the application.
    • If specified, this query MUST be an SQL SELECT statement that returns at least one row.
    • Plex-XML will return a database connection error page to the user if the database connection is not valid.

Example for Tomcat < 5.5

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/@projectname@" docBase="@projectname@" privileged="false" debug="0">
<Logger className="org.apache.catalina.logger.SystemOutLogger" verbosity="2"/>
 <Resource name="jdbc/Financial" type="javax.sql.DataSource"/>
  <ResourceParams name="jdbc/Financial">
Personal tools