Major difference between Tomcat 5.0 and Tomcat 5.5

The Apache Jakarta Tomcat is the most widely opensource web servlet/jsp container used nowdays. As more and more new versions are available, it is necessary to mention some core differences in syntax or format of configuration files between these versions. In this article I would like to show one valuable difference between Tomcat 5.0.x and Tomcat 5.5.x. When deploying an application into web server some properties should be specified in server.xml file which is common for all applications deployed on the same web server or in the context.xml file specific to each application. In the version Tomcat 5.0.x the configuration file should be consisted of a list of parameters of a following format:

<Resource name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/TestDB">
<parameter>
<name>username</name>
<value>javauser</value>
</parameter>
<parameter>
<name>password</name>
<value>javauser</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
</parameter>
</ResourceParams>

In this example we’re specifing the connection properties for MySQL database as a parameters. In versions 5.0.x this will work without any problems, but if you try to change your version of Tomcat and try to use the same configuration files you will fail. The problem is that in versions 5.5.x the propeties should be specified as attributes of Resource element as in the following example:

<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/>

So when upgrading your Tomcat version take care of changing the configuration files to reflect the syntax and format of the new version.

You might also like