I want to run "mvn tomcat:run" from the command line, but how can I edit the server.xml to set maxHttpHeaderSize="65536" in the connectors? Or can I configure the connectors in the pom.xml?
Cheers
Nik
The org.codehaus.mojo:tomcat-maven-plugin will let you set the path to the server.xml file in the configuration section:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<serverXml>path_to_server_xml_file</serverXml>
</configuration>
</plugin>
Unfortunately, after doing some research, I don't think there's a way to edit server.xml's connectors. mvn tomcat:run
uses an embedded Tomcat.
Unless someone finds something, it seems like your best bet will be to move to the maven cargo plugin and ZIP up your own Tomcat installation with your custom server.xml
.
<cargo containerId="tomcat7x" [...]>
<zipUrlInstaller
installUrl="file://tomcat-custom.zip",
installDir="target/installs"/>
[...]
</cargo>
Or something of the sort...
I have been experimenting with using the serverXml parameter for the tomcat:run
goal (http://tomcat.apache.org/maven-plugin-2/tomcat6-maven-plugin/run-mojo.html#serverXml).
The following server.xml
seems to run with no errors, but without a Context
element it does not load the webapp. I think if I copied my Context
element from src/main/webapp/META-INF/context.xml to inside the Host
element, it might work just fine:
<?xml version='1.0' encoding='utf-8'?>
<Server port="-1" shutdown="SHUTDOWN">
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1" />
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="webapps">
</Host>
</Engine>
</Service>
</Server>
To run with this server, I pass the serverXml as a property on the Maven command line:
mvn -Dmaven.tomcat.serverXml=src/main/resources/server.xml tomcat:run
The goal might have to be tomcat6:run
if you are using a version of the plugin that supports both Tomcat 6 and 7.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With