How to start Tomcat with a specific server.xml under Windows?

11,075

I've got it. I took me the half night, but it works :)

At first I also thought of symbolic links, but under Windows it's not a thing you would like to use. My second thought was modifying catalina.bat, but that's not that easy. And different CATALINA_HOME's is not what I really want.

So what have I done? I've provided the server.xml as a parameter to catalina.bat.

catalina.bat start -config \conf\server_test.xml

Nice and easy :)

You can have a lot of server configuration files and provide the one you need to the start and stop script. The tricky thing was that the Catalina class gives you the wrong usage information :

usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { start | stop }

But if you exchange the parameters and first provide "start" or "stop" and then the "-config ..." argument, everything works.

Also very nice is that you can use this solution the create different run configuration in IntelliJ IDEA. I have one where the Tomcat connects to a local database and one connecting to a development database. For each I have a different server.xml.

I hope this helps.

Regards, Sebastian

Share:
11,075
seb
Author by

seb

Updated on June 20, 2022

Comments

  • seb
    seb almost 2 years

    I want to start Tomcat 6 with special configuration sometimes, not using the "server.xml". So I created another xml file named server_test.xml. Now I want to tell tomcat to use this configuration. How is this done?

    I found nearly nothing searching the web. Only that: "Use different server.xml file in Tomcat configuration: ./tomcat.sh start -f /var/tmp/server-${USER}.xml"

    This is exactly what I want. Maybe this is working for linux systems but not for windows. Any ideas out there?