Error
Maven failed to build the project (or a list of projects) due to lack of resources problem as shown below.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (default-testCompile) on project com.javacreed.examples.maven.error: Compilation failure [ERROR] Failure executing javac, but could not parse the error: [ERROR] [ERROR] [ERROR] The system is out of resources. [ERROR] Consult the following stack trace for details. [ERROR] java.lang.OutOfMemoryError: PermGen space [ERROR] at java.lang.ClassLoader.defineClass1(Native Method) [ERROR] at java.lang.ClassLoader.defineClass(ClassLoader.java:791) [ERROR] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [ERROR] at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) [ERROR] at java.net.URLClassLoader.access$100(URLClassLoader.java:71) [ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:361) [ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:355) [ERROR] at java.security.AccessController.doPrivileged(Native Method) [ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:354) [ERROR] at org.codehaus.plexus.compiler.javac.IsolatedClassLoader.loadClass(IsolatedClassLoader.java:56) [ERROR] at com.sun.tools.javac.comp.MemberEnter. (MemberEnter.java:95) [ERROR] at com.sun.tools.javac.comp.MemberEnter.instance(MemberEnter.java:85) [ERROR] at com.sun.tools.javac.comp.Enter. (Enter.java:126) [ERROR] at com.sun.tools.javac.comp.Enter.instance(Enter.java:114) [ERROR] at com.sun.tools.javac.comp.Check. (Check.java:96) [ERROR] at com.sun.tools.javac.comp.Check.instance(Check.java:86) [ERROR] at com.sun.tools.javac.code.Types. (Types.java:101) [ERROR] at com.sun.tools.javac.code.Types.instance(Types.java:88) [ERROR] at com.sun.tools.javac.jvm.ClassReader. (ClassReader.java:264) [ERROR] at com.sun.tools.javac.jvm.ClassReader.instance(ClassReader.java:226) [ERROR] at com.sun.tools.javac.main.JavaCompiler. (JavaCompiler.java:331) [ERROR] at com.sun.tools.javac.main.JavaCompiler.instance(JavaCompiler.java:88) [ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:424) [ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:353) [ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:342) [ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:333) [ERROR] at com.sun.tools.javac.Main.compile(Main.java:94) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.lang.reflect.Method.invoke(Method.java:601) [ERROR] at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:554) [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Solution
We need to increase the MaxPermSize
( Documentation ) to make sure that Maven has enough memory to compile all projects. Here is an article about Permanent Generation should you like to read more about this topic.
This can be achieved by setting the operating system environment variableMAVEN_OPTS
and include the MaxPermSize
setting as shown below.
MAVEN_OPTS -XX:MaxPermSize=128m
If you have a command prompt open, then you need to close it as the newly added environment variables will not be available. In order to make sure that the setting has effect, execute the following command to print the value of the environment variable.
C:\Users\Albert\javacreed >echo %MAVEN_OPTS%
-XX:MaxPermSize=128m
The echo
command should print the value set to the MAVEN_OPTS
environment variable.