Sebi
Sebi

Reputation: 9043

Increase memory of tomcat7 maven plugin?

I want to start an embedded tomcat7 instance directly from maven using the tomcat7-maven-plugin. This is working fine, but the Tomcat started doesn't seem to have enough memory. I suspect that I would need to set

-XX:MaxPermSize=256m

but I can't figure out how to do it.

The documentation says one should use the "systemProperties" element in the "configuration" section of the plugin. However, the options are specified as XML elements and would need to look like that:

<configuration>
  <systemProperties>
    <XX:MaxPermSize>256m</XX:MaxPermSize>
  </systemProperties>
</configuration>

But that's of course not possible as it breaks the XML (XX is interpreted as a namespace).

Of course I could get around this problem by setting environment variable

MAVEN_OPTS=-XX:MaxPermSize=256m

but I would prefer to only increase it for the embedded Tomcat. Any ideas how to do that?

Upvotes: 28

Views: 24487

Answers (3)

Hombre
Hombre

Reputation: 41

This one worked for me:

<plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>...</version>
    <configuration>
        <container>...</container>
        <configuration>
            <type>standalone</type>
            <home>...</home>
            <properties>
                <cargo.jvmargs>-Xmx4096m</cargo.jvmargs>
            </properties>
        </configuration>
        <deployables>...</deployables>
    </configuration>
</plugin>

It starts up my tomcat8 in a new JVM with argument "-Xmx4096m".

Upvotes: 0

Lennart Kramer
Lennart Kramer

Reputation: 141

As most said in the comments above the properties in pom.xml has no effct. What worked for me was setting my MAVEN_OPTS

MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m"

Or on Windows in a cmd terminal:

set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=256m

For mac/linux users, just add an export statement to your ~/.profile (or similar file name). For example:

export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m"

And restart your shell.

Upvotes: 14

Rene Herget
Rene Herget

Reputation: 1526

You can set the properties in this way

<configuration>
  <systemProperties>
    <JAVA_OPTS>-Xms256m -Xmx512m -XX:MaxPermSize=256m</JAVA_OPTS>
  </systemProperties>
</configuration>

Upvotes: 3

Related Questions