Mvn tomcat: run - how do I change server.xml?

I want to run "mvn tomcat: run" from the command line, but how can I edit server.xml to set maxHttpHeaderSize = "65536" in the connectors? Or can I customize the connectors in pom.xml?

Greetings

Nick

+7
java tomcat
source share
4 answers

Unfortunately, after some research, I don't think there is a way to edit server.xml connections. mvn tomcat:run uses the built-in Tomcat.

If someone doesn't find something, it seems best to switch to the maven transport plugin and create your own Tomcat installation using your custom server.xml .

 <cargo containerId="tomcat7x" [...]> <zipUrlInstaller installUrl="file://tomcat-custom.zip", installDir="target/installs"/> [...] </cargo> 

Or something like that...

+6
source share

org.codehaus.mojo: tomcat-maven-plugin will allow you to 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> 
+7
source share

I experimented using the serverXml parameter for the tomcat:run target (http://tomcat.apache.org/maven-plugin-2/tomcat6-maven-plugin/run-mojo.html#serverXml).

The following server.xml seems to work without errors, but without the Context element it does not load webapp. I think if I copied my Context element from src / main / webapp / META-INF / context.xml inside the Host element, it might work 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 work with this server, I pass serverXml as a property on the Maven command line:

 mvn -Dmaven.tomcat.serverXml=src/main/resources/server.xml tomcat:run 

The target could be tomcat6:run if you are using a version of the plugin that supports both Tomcat 6 and 7.

+3
source share

see http://docs.codehaus.org/display/CARGO/Custom+File+Configurations

I think you can do it like this and put your own server.xml in your project:

 <configuration> <type>standalone</type> <configfiles> <configfile> <file>${basedir}/src/main/resources/server.xml</file> <todir>conf</todir> </configfile> </configfiles> </configuration> 

and use the default load server.xml as a template to get a property replacement:

 <Server port="@cargo.rmi.port@" shutdown="SHUTDOWN" debug="@catalina.logging.level@"> <Service name="Catalina" debug="@catalina.logging.level@"> <Connector port="@cargo.servlet.port@" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" scheme="@cargo.protocol@" secure="@catalina.secure@" debug="@catalina.logging.level@" emptySessionPath="@catalina.connector.emptySessionPath@" URIEncoding="@catalina.servlet.uriencoding@" /> <!-- Define an AJP 1.3 Connector on port @cargo.tomcat.ajp.port@ --> <Connector port="@cargo.tomcat.ajp.port@" protocol="AJP/1.3" redirectPort="8443" /> <Engine name="Catalina" defaultHost="@cargo.hostname@" debug="@catalina.logging.level@"> <Realm className="org.apache.catalina.realm.MemoryRealm" /> <!-- Note: There seems to be a bug in Tomcat 5.x if the debug attribute is present. Ideally we would have written: debug="@catalina.logging.level@" However, doing this result in a NullPointerException in ExpandWar.java at line 145. --> <Host name="@cargo.hostname@" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <!-- Contexts to explicitely point to where the wars are located --> @tomcat.webapps@ <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="@cargo.hostname@_access_log." suffix=".txt" pattern="common" resolveHosts="false"/> </Host> </Engine> </Service> </Server> 
+1
source share

All Articles