Stepan Vavra
Stepan Vavra

Reputation: 4054

Set JARs to skip in order to speed up Tomcat 7 maven plugin startup

Is there a simple way (e.g., directly from tomcat7-maven-plugin configuration) to specify which JARs should be skipped during Tomcat startup in order to speed it up?

The Tomcat 7 documentation encourages to use a system property org.apache.catalina.startup.ContextConfig.jarsToSkip (see http://wiki.apache.org/tomcat/HowTo/FasterStartUp#JAR_scanning), but when set from maven configuration, it does not work.

Upvotes: 1

Views: 1076

Answers (1)

Stepan Vavra
Stepan Vavra

Reputation: 4054

After inspecting the sources of tomcat7-maven-plugin, I found a workaround to achieve jars skipping. (It may however stop working with future releases of Maven Tomcat 7 plugin.)

        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <configuration>
                <path>/${project.artifactId}</path>
                <port>8080</port>
                <systemProperties>
                    <org.apache.catalina.startup.ContextConfig.jarsToSkip>*</org.apache.catalina.startup.ContextConfig.jarsToSkip>
                    <!-- work around .. see: https://issues.apache.org/jira/browse/MTOMCAT-281 -->
                    <catalina.config>${project.baseUri}/target/tomcat/logs</catalina.config>
                </systemProperties>
            </configuration>
        </plugin>

As described in a related bug (https://issues.apache.org/jira/browse/MTOMCAT-281), the problem is that Tomcat blindly overrides all system properties with properties from tomcat-embed-core-7.0.47.jar!/org/apache/catalina/startup/catalina.properties. As a result, the value of org.apache.catalina.startup.ContextConfig.jarsToSkip system property specified in plugin configuration is overridden.

Upvotes: 4

Related Questions