Maven编译:执行javac失败

01e*_*1es 11 java stack-overflow maven-2

以下是我们尝试使用Maven 2.2.1和JDK 1.6.0_23在Windows Server 2003下编译新签出的代码时遇到的异常.运行具有相同Maven和JDK版本的Ubuntu的几台机器在编译完全相同的源时没有任何问题.

试过提供替代Maven选项(即MAVEN_OPTS = -Xms256m -Xmx1024m)无济于事.

可能是什么原因导致这个问题以及可能的解决方案是什么?感谢名单.

[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
Run Code Online (Sandbox Code Playgroud)

Jig*_*shi 13

尝试

MAVEN_OPTS=-Xms256m -Xmx1024m -Xss1024k

注意:-Xss,应根据可用的硬件设置

  • +1,因为这帮助我弄清楚我假设的解决方案是 http://stackoverflow.com/questions/9229020/jenkins-not-showing-maven-compiler-errors/10857174#10857174(或者至少是我的问题,如我在那边的回答中所详述) (2认同)

dog*_*ane 8

您的任何代码是否都是自动生成的,例如来自WSDL?你能确定哪个类导致问题吗?这样做的一种方法是删除一些源代码,重新编译并重复,直到缩小到一小部分类.

你有任何大班或长方法吗?如果是这样,你应该重构.

增加堆栈大小.我认为默认值是512k.将编译器配置更改为:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>2.3.2</version>
  <configuration>
    <compilerArgument>-J -Xss10M</compilerArgument>
  </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

  • +1 compilerArgument对我不起作用(由于某种原因,javac参数无效).但是compilerArguments(复数)确实如此.作为旁注,maven文档(http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#compilerArguments)声明必须将forkArgument和compilerArguments设置为true.使用. (3认同)