My linux world » Tomcat Survival Guide

Tomcat Survival Guide


Memory

CATALINA_OPTS is used to control Tomcat environment options, whereas JAVA_OPTS controls the environment options at a higher level ie. for any Java library.

In $CATALINA_HOME/bin/startup.sh or in your shell enter the following command:

   export CATALINA_OPTS=”-Xms1024m -Xmx1024m”

Context File

To configure the Tomcat’s resource factory, you can use :

An example of a context file:

  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
  <Context path="/myWebAppName" antiJARLocking="true" antiResourceLocking="true">
    <Resource 
       name="jdbc/EmployeeDB" 
       auth="Container"
       type="javax.sql.DataSource" 
       username="dbusername" 
       password="dbpassword"
       driverClassName="org.hsql.jdbcDriver" 
       url="jdbc:HypersonicSQL:database"
       maxActive="8" 
       maxIdle="4"
     />
 
     <Parameter name="myParameterName" value="myParameterValue" override="false"/>
 
  </Context>

Some additional properties handle connection validation:

Properties Description
driverClassName Fully qualified Java class name of the JDBC driver to be used.
username Database username to be passed to our JDBC driver.
password Database password to be passed to our JDBC driver.
url Connection URL to be passed to our JDBC driver. (For backwards compatibility, the property driverName is also recognized.)
initialSize The initial number of connections that will be created in the pool during pool initialization. Default: 0
maxActive The maximum number of connections that can be allocated from this pool at the same time. Default: 8
minIdle The minimum number of connections that will sit idle in this pool at the same time. Default: 0
maxIdle The maximum number of connections that can sit idle in this pool at the same time. Default: 8
maxWait The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception. Default: -1 (infinite)
antiJARLocking If true, the Tomcat classloader will take extra measures to avoid JAR file locking when resources are accessed inside JARs through URLs. This will impact startup time of applications, but could prove to be useful on platforms or configurations where file locking can occur. If not specified, the default value is false.
antiResourceLocking If true, Tomcat will prevent any file locking. This will significantly impact startup time of applications, but allows full webapp hot deploy and undeploy on platforms or configurations where file locking can occur. If not specified, the default value is false.

Copyright © 2024 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.