Configuration for Tomcat versions 5.5 and above

   Tomcat website

There are 3 main steps for enabling primrose to run within Tomcat.

  1. Install jar file

    Copy primrose.jar into Tomcat's user lib directory (eg TOMCAT_HOME/common/lib in v5.5 or TOMCAT_HOME/lib in v6)

  2. Configure server.xml to load primrose:

    Under GlobalNamingResources tag in server.xml, define a pool, and a web console. There are two sections to add :
    • Define a pool or two to be loaded

      Note that you only require a single primrose.config file, yet each pool must be configured in server.xml in order for Tomcat to load them.
      
      	<!-- Define a pool called 'examplePool' -->
      	<Resource
      		name="examplePool" auth="Container"
      		type="uk.org.primrose.vendor.tomcat.PrimroseDataSource"
      		description="The examplePool database pool"
      		factory="uk.org.primrose.vendor.tomcat.PrimroseDataSourceFactory"
      
      		poolName="examplePool"
      		primroseConfigFile="/usr/tomcat/conf/primrose.config"
      
      	/>
      
      	<!-- Define another pool called 'anotherPool' -->
      	<Resource
      		name="anotherPool" auth="Container"
      		type="uk.org.primrose.vendor.tomcat.PrimroseDataSource"
      		description="The anotherPool database pool"
      		factory="uk.org.primrose.vendor.tomcat.PrimroseDataSourceFactory"
      
      		poolName="anotherPool"
      		primroseConfigFile="/usr/tomcat/conf/primrose.config"
      
      	/>
      
      				
      Make sure that the primroseConfigFile exists, and is configured correctly (see primroseConfig.html).

    • Define an webconsole to provide web access to all pools (optional)

      
      	<!-- Define a webconsole to provide web access to all pools (optional) -->
      	<Resource
      		name="webconsole" auth="Container"
      		type="uk.org.primrose.vendor.tomcat.WebConsoleFactory"
      		description="The primrose web console pool monitor"
      		factory="uk.org.primrose.vendor.tomcat.WebConsoleFactory"
      
      		username="admin"
      		password="admin"
      		port="8090"
      		logFile="/usr/tomcat/logs/wbconsole.log"
      		logLevel="verbose,info,warn,error,crisis"
      
      	/>
      				
      Make sure that the logFile directory exists, and can be written to by tomcat.
      Also make sure that the port is available.
      You may password protect the webconsole - if you not wish to, then just leave out the username and password elements.

  3. Configure server.xml to link the configured pools to your webapps:

    At the end of your Host tag, add/alter the Context tags :
    		<Context path="/RequestServices" debug="0" reloadable="true" crossContext="true">
    			<ResourceLink
    				global="examplePool"
    				name="examplePool"
    				type="javax.sql.DataSource"/>
    
    			<ResourceLink
    				global="anotherPool"
    				name="anotherPool"
    				type="javax.sql.DataSource"/>
    		</Context>
    				
Tomcat should now be configured successfully to run primrose.