How to run Tomcat with a specific server.xml on Windows?

I want to run Tomcat 6 with a special configuration sometimes, without using "server.xml". So I created another xml file called server_test.xml . Now I want to tell tomcat to use this configuration. How it's done?

I almost did not find anything on the Internet. Just this: "Use another server.xml file in your Tomcat configuration: ./ tomcat.sh start -f / var / tmp / server - $ {USER} .xml"

This is exactly what I want. Perhaps this works for Linux systems, but not for windows. Any ideas there?

+7
java tomcat
source share
3 answers

I have it. I took half the night, but it works :)

At first I also thought about symbolic links, but under Windows this is not what you would like to use. My second thought was to change catalina.bat , but it's not so simple. And different CATALINA_HOME not what I really want.

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

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

Nice and easy :)

You can have many server configuration files and specify the one you need to start and stop the script. The difficulty is that the Catalina class gives incorrect usage information:

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

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

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

Hope this helps.

Regards, Sebastian

+14
source share

It doesn't seem like there is a (documented) option that you can pass startup.sh or catalina.sh to change that.

Perhaps you can set server.xml as a symbolic link to the file you really want to use and just change the symbolic link before starting the server, when do you want to change it?

Otherwise, you can play using different values ​​of $CATALINA_HOME , but this will require duplication of all directory structures.

0
source share

tomcat.sh does not exist with 3.x, and to be honest, I don’t remember the -f option then.

You have two options here:

A) You can configure multiple instances of tomcat as described here and switch between them by pointing CATALINA_BASE to the one you need.

B) You can create several server.xml files with different names (for example, server-1.xml , server-2.xml , etc.) and write a simple batch script that will copy the one you specified as an argument to the command line, into the actual server.xml and then run Tomcat.

0
source share

All Articles