java.lang.OutOfMemoryError: PermGen space maven

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

MAVEN_OPTS

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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值