Sometimes Maven will fail when running the test cases with this error.

java.lang.OutOfMemory

This means that Maven has run out of available system memory.

To increase the memory available to Maven, the environment variable MAVEN_OPTS should be set to the value -Xmx1024m -XX:MaxPermSize=128m, or more depending on the amount of memory you have available on your machine.

This is the command for increasing the memory using the bash shell. Add this to your ~/.bash_profile to have it available in all your sessions.

export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m"

This is the equivalent command in csh. Add this to your ~/.cshrc file to have this setting available in all your sessions.

setenv MAVEN_OPTS "-Xmx1024m -XX:MaxPermSize=128m"

Finally, if you are using Windows, then this command can be used from the command prompt.

set MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m"

To make this variable permanent on Windows, use the Control Panel -> System dialog. Select the Advanced tab and click Environment Variables. Under the System Variables table, click New. Type MAVEN_OPTS for the Variable name and -Xmx1024m -XX:MaxPermSize=128m for the Variable value.