i have a little problem and see no solution for it.
I need flexible ports for my tomcat. I want to set a port variable in a properties file and tomcat read this and start the server on this port. I know that tomcat can’t read from properties but he can read system variables/properties.
I build my project and tomcat with ant, this means the solution lies in ant.
server.xml
<Connector
port="${tomcat.http.port}" maxHttpHeaderSize="8192" ...
</Connector>
build.xml
<exec dir="${basedir}/tomcat/bin" executable="${basedir}/tomcat/bin/catalina.sh" failonerror="true" output="${basedir}/tomcat/logs/testrun.log">
<arg value="start" />
</exec>
project.properties
tomcat.http.port=42
What I do, I have a server.xml tomcat file with placeholder properties in:
Then in my ant build.xml:
And run your ant build with -Dhttp.port=42 or put that in a properties file loaded by ant.