Tomcat JNDI configuration for auto redeploy

With thanks to http://www.mail-archive.com/users@tomcat.apache.org/msg74521.html

Although it’s deprecated putting the context in server.xml seems to work quite nicely
however if you want to auto deploy e.g. on a CI server then you need to get a bit cleverer….

Don’t keep the application in the appBase – locate it outside of
Tomcat’s directory structure, and use the docBase attribute of the
element to tell Tomcat where to find it. Replace the .war file at your
leisure, and then do a touch of the .xml file to trigger an application redeployment

1) I have created a folder with absolute path:
##war directory##
2) In this folder I have placed my WAR file, ##Application##.war
3) In apache-tomcat-6.0.20/conf/Catalina/localhost
I have placed a file called ##Application.xml## (contents of file below).



<?xml version="1.0" encoding="UTF-8"?>

<Context docBase="##war directory##/##Application.war##">
<Resource name="jdbc/postgres" auth="Container"
type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/XXXXXX"
username="YYYYYY" password="ZZZZZZ" maxActive="20"
maxIdle="10"
maxWait="-1"/>
</Context>

Leave a Reply

Your email address will not be published. Required fields are marked *