问题
Here is an exception we get when trying to compile a freshly checked out code under Windows Server 2003 with Maven 2.2.1 and JDK 1.6.0_23. Several machines running Ubuntu with the same Maven and JDK version have no problems at all compiling the exact same source.
Have tried providing alternative Maven options (i.e. MAVEN_OPTS=-Xms256m -Xmx1024m) to no avail.
What could be the cause of this problem and what would be a possible solution? Thanx.
[INFO] Compilation failure
Failure executing javac, but could not parse the error:
The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:1799)
at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1522)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:377)
at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1241)
at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1210)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
... then trace repeats multiple times
回答1:
try
MAVEN_OPTS=-Xms256m -Xmx1024m -Xss1024k
Note: -Xss , should be set according to hardware available
回答2:
Is any of your code being auto-generated e.g. from a WSDL? Can you pinpoint which class(es) is causing the problem? One way of doing this would be to remove some of your source, recompile and repeat until you have narrowed down to a small subset of classes.
Do you have any large classes or long methods? If so, you should refactor.
Increase the stack size. I think the default is 512k. Change the compiler configuration to:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compilerArgument>-J -Xss10M</compilerArgument>
</configuration>
</plugin>
回答3:
What could be the cause of this problem and what would be a possible solution? Thanx.
Here are some possible causes:
- The stack is actually too small. Fix - set a larger stack size.
- You are compiling a pathological class or method. Fix - try and identify the file, identify the pathology, and refactor it.
- You've run into a java compiler bug. Fix - try and identify the file, identify what is triggering the bug, and refactor it to workaround the bug.
- You've somehow managed to get a corrupt JAR file into the Maven local repository on the Windows machine. Fix - wipe the repository and rebuild. (This may entail re-downloading a bunch of artifacts and plugins.)
回答4:
The comment below is a working answer
set MAVEN_OPTS=-Xms256m -Xmx1024m -Xss1024k -XX:MaxPermSize=384m"
回答5:
I have also come across the same problem. To fix it what I did, is- I ran the below command in console
set MAVEN_OPTS=-Xms256m -Xmx1024m -Xss1024k *-XX:MaxPermSize=384m
instead of-
set MAVEN_OPTS=-Xms256m -Xmx1024m -Xss1024k *-XX:MaxPermSize=128m
Try this, It would definitely work. If still you get same problem then replace
-XX:MaxPermSize=384m
to
-XX:MaxPermSize=512m
来源:https://stackoverflow.com/questions/4782509/maven-compilation-failure-executing-javac