Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

You ever want to run multiple instance of tomcats with the same install base, but tired of copy and setup server.xml file? Attached are couple Groovy scripts that create new server instances, and a tool to quickly setup a new Groovlet webapp.


Assume you have installed Tomcat6 or Tomcat5 in /opt/tomcat directory.

Code Block
ztoy:~/s zemian$ ./NewTomcatInstance.groovy /opt/tomcat mytomcat
Create new instance dir /opt/tomcat/instances/mytomcat
Create server.xml file with httpPort 8081, httpPort 8081
Create tomcat-user.xml file with manager role user.
Create file
Create ROOT webapp
Create ROOT webapp web.xml
Create ROOT webapp index.jsp
To Start Server: /opt/tomcat/bin/ start
To View Browser:

Run it again to create another instnace with mytomcat2, and it should configure to port 8082 and so on...

Each new server instance will contains a ROOT webapp that list all other webapps for quick links.

Also, the server instance is configured with Tomcat manager webapp enabled with a user: admin. If you are in this stage, you ought to know where to look for your password. (smile)


As stated in Tomcat documentation, enabling Tomcat manager is considered a potential security hole as it enable authenticated users to have total control over your webapps. It's enabled in this script for the sake of easy setup and quick management.

To remove a previous installed instance

Code Block
ztoy:~/s zemian$ ./delete_tomcat_instance.groovy /opt/tomcat mytomcat


This script will create a new webapp directory structure with all the Groovlet setup ready.

Code Block
ztoy:~/s zemian$ ./NewWebapp.groovy /opt/tomcat/instances/mytomcat/webapps mywebapp
Create webapp
Copy groovy jar to lib
     [copy] Copying 1 file to /opt/tomcat/instances/mytomcat/webapps/mywebapp/WEB-INF/lib
Create webapp web.xml
Create webapp index.gsp
Create webapp mysqlreport.groovy
Create webapp mysqlreport.gsp

Start your server and you have a webapp ready to go!

The mysqlreport.groovy is a updated version of Andrew Glover's
And you will need mysql jdbc driver jar copy into mywebapp/WEB-INF/lib to work.