Configuration for Tomcat version 5.0 and below
There are 3 main steps for enabling primrose to run within Tomcat (note this guide is for version 5.0 and below only - not 5.5 or above).
Install jar file
Copy primrose.jar into Tomcat's user lib directory (eg TOMCAT_HOME/common/lib)
Configure server.xml to load primrose:
UnderGlobalNamingResourcestag 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.Make sure that the primroseConfigFile exists, and is configured correctly (see primroseConfig.html).<!-- Define a pool called 'examplePool' --> <Resource name="examplePool" auth="Container" type="uk.org.primrose.vendor.tomcat.PrimroseDataSource" description="The examplePool database pool"> </Resource> <ResourceParams name="examplePool"> <parameter> <name>factory</name> <value>uk.org.primrose.vendor.tomcat.PrimroseDataSourceFactory</value> </parameter> <parameter> <name>poolName</name> <value>examplePool</value> </parameter> <parameter> <name>primroseConfigFile</name> <value>/usr/tomcat/conf/primrose.config</value> </parameter> </ResourceParams> <!-- Define a pool called 'anotherPool' --> <Resource name="anotherPool" auth="Container" type="uk.org.primrose.vendor.tomcat.PrimroseDataSource" description="The anotherPool database pool"> </Resource> <ResourceParams name="anotherPool"> <parameter> <name>factory</name> <value>uk.org.primrose.vendor.tomcat.PrimroseDataSourceFactory</value> </parameter> <parameter> <name>poolName</name> <value>anotherPool</value> </parameter> <parameter> <name>primroseConfigFile</name> <value>/usr/tomcat/conf/primrose.config</value> </parameter> </ResourceParams>
-
Define an webconsole to provide web access to all pools (optional)
Make sure that the logFile directory exists, and can be written to by tomcat.<!-- 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 anotherPool database pool"> </Resource> <ResourceParams name="webconsole"> <parameter> <name>factory</name> <value>uk.org.primrose.vendor.tomcat.WebConsoleFactory</value> </parameter> <parameter> <name>username</name> <value>admin</value> </parameter> <parameter> <name>password</name> <value>admin</value> </parameter> <parameter> <name>port</name> <value>8090</value> </parameter> <parameter> <name>logFile</name> <value>/usr/tomcat/logs/wbconsole.log</value> </parameter> <parameter> <name>logLevel</name> <value>verbose,info,warn,error,crisis</value> </parameter> </ResourceParams>
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.
-
Configure server.xml to link the configured pools to your webapps:
At the end of yourHosttag, add/alter theContexttags :<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>


