maven build在某些环境中失败,但随后成功获取同一目录的副本

时间:2018-03-15 17:41:07

标签: java git maven jenkins

我希望有人可以提供一些见解,一些建议,甚至只是指出我试图解决这个奇怪问题的方向。

在某些环境中,例如我们的Jenkins服务器,甚至有时在开发人员机器上,如果从git repo克隆这个特定项目,然后在其上运行maven构建,则构建失败,打印大量递归栈跟踪并且抛出stackoverlow错误。

$ git clone git@git@bitbucket.org:company/project.git
$ cd project
$ mvn clean install -DskipTests
$ <Fails with stacktrace seen below>

在构建失败的情况下,如果我使用“cp -r”制作项目目录的副本,然后在新创建的目录中运行构建...构建成功没有任何问题。 (!)

$ cp -r project project_copy-r
$ cd project_copy-r
$ mvn clean install -DskipTests
$ <Build succeeds with no errors>

如果我使用“cp -a”制作项目目录的副本,然后在新复制的目录中运行maven构建,则构建将失败并返回与原始目录相同的错误。 (!!)

$ cp -a project project_copy-a
$ cd project_copy-a
$ mvn clean install -DskipTests
$ <Fails with stacktrace seen below>

如果我使用“cp -rp”制作项目目录的副本,然后在新创建的目录中运行构建,则构建将再次失败并出现相同的错误。

$ cp -rp project project_copy-rp
$ cd project_copy-rp
$ mvn clean install -DskipTests
$ <Fails with stacktrace seen below>

因此......使用“-a”或“-rp”标志复制的副本与复制命令中的“-r”标志之间的区别是不同的。这里显而易见的选择是,项目目录中的某些内容具有过于严格的权限,只有在使用“-r”标志时才会被删除。

但是,如果我运行“sudo chmod -R 755 project_copy-rp”,我仍然会遇到相同的构建错误。如果我然后运行“sudo chown -R me:me project_copy-rp”

那么同上
$ sudo chmod -R 755 project_copy-rp 
$ cd project_copy-rp
$ mvn clean install -DskipTests
$ <Fails with stacktrace seen below>
$
$ chown -R me:me ../project_copy-rp 
$ mvn clean install -DskipTests
$ <Fails with stacktrace seen below>

此外,一旦使用“-a”或“-rp”复制了项目文件夹,无论隐藏什么问题,似乎都会对副本“锁定”。此时仅使用“-r”标志重新复制先前创建的目录不会导致构建错误消失。

$ cp -a project project_copy-a
$ cp -r project_copy-a project_copy-a-r
$ cd project_copy-a-r
$ mvn clean install -DskipTests
$ <Fails with stacktrace seen below>

在Jenkins服务器上,构建应该由包含Maven 3和Oracle Java 8的docker镜像完成。构建再次失败并具有相同的堆栈跟踪。为了测试这个问题,我git将项目的副本克隆到Jenkins服务器上的主目录,安装了Maven 3和Oracle Java 8,并从那里运行了构建。它成功了,没有错误。

正如我所说 - 如果有人有任何想法,我会很感激。

堆栈跟踪:

[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.8:compile (default-compile) on project project-web: AJC compiler errors:
[ERROR] abort trouble in:
[ERROR] public class com.company.project.view.evaluation.EvaluationTagTreeInitTask extends java.lang.Object implements com.company.project.view.Task:
[ERROR] private final java.util.List rootNodes [Signature(Ljava/util/List<Lcom/company/project/view/tree/EvalTreeInputNode<TT;>;>;)]
[ERROR] private final com.google.common.base.Supplier rootNodeFactory [Signature(Lcom/google/common/base/Supplier<Lcom/google/common/base/Optional<Lcom/company/project/view/tree/EvalTreeInputNode<TT;>;>;>;)]
[ERROR] public void <init>(java.util.List, com.google.common.base.Supplier)    org.aspectj.weaver.MethodDeclarationLineNumber: 18:587
[ERROR] :
[ERROR] ALOAD_0     // Lcom/company/project/view/evaluation/EvaluationTagTreeInitTask; this   (line 18)
[ERROR] INVOKESPECIAL java.lang.Object.<init> ()V
[ERROR] constructor-execution(void com.company.project.view.evaluation.EvaluationTagTreeInitTask.<init>(java.util.List, com.google.common.base.Supplier))
[ERROR] |               ALOAD_0     // Lcom/company/project/view/evaluation/EvaluationTagTreeInitTask; this   (line 22)
[ERROR] |               ALOAD_1     // Ljava/util/List; rootNodes
[ERROR] | field-set(java.util.List com.company.project.view.evaluation.EvaluationTagTreeInitTask.rootNodes)
[ERROR] | |             PUTFIELD com.company.project.view.evaluation.EvaluationTagTreeInitTask.rootNodes Ljava/util/List;
[ERROR] | field-set(java.util.List com.company.project.view.evaluation.EvaluationTagTreeInitTask.rootNodes)
[ERROR] |               ALOAD_0     // Lcom/company/project/view/evaluation/EvaluationTagTreeInitTask; this   (line 23)
[ERROR] |               ALOAD_2     // Lcom/google/common/base/Supplier; rootNodeFactory
[ERROR] | field-set(com.google.common.base.Supplier com.company.project.view.evaluation.EvaluationTagTreeInitTask.rootNodeFactory)
[ERROR] | |             PUTFIELD com.company.project.view.evaluation.EvaluationTagTreeInitTask.rootNodeFactory Lcom/google/common/base/Supplier;
[ERROR] | field-set(com.google.common.base.Supplier com.company.project.view.evaluation.EvaluationTagTreeInitTask.rootNodeFactory)
[ERROR] |               RETURN   (line 24)
[ERROR] constructor-execution(void com.company.project.view.evaluation.EvaluationTagTreeInitTask.<init>(java.util.List, com.google.common.base.Supplier))
[ERROR] end public void <init>(java.util.List, com.google.common.base.Supplier)
[ERROR] 
[ERROR] public void execute(com.company.project.time.Time) throws java.lang.Exception    org.aspectj.weaver.MethodDeclarationLineNumber: 27:817
[ERROR] :
[ERROR] method-execution(void com.company.project.view.evaluation.EvaluationTagTreeInitTask.execute(com.company.project.time.Time))
[ERROR] |               ALOAD_0     // Lcom/company/project/view/evaluation/EvaluationTagTreeInitTask; this   (line 29)
[ERROR] | field-get(com.google.common.base.Supplier com.company.project.view.evaluation.EvaluationTagTreeInitTask.rootNodeFactory)
[ERROR] | |             GETFIELD com.company.project.view.evaluation.EvaluationTagTreeInitTask.rootNodeFactory Lcom/google/common/base/Supplier;
[ERROR] | field-get(com.google.common.base.Supplier com.company.project.view.evaluation.EvaluationTagTreeInitTask.rootNodeFactory)
[ERROR] | method-call(java.lang.Object com.google.common.base.Supplier.get())
[ERROR] | |             INVOKEINTERFACE com.google.common.base.Supplier.get ()Ljava/lang/Object;
[ERROR] | method-call(java.lang.Object com.google.common.base.Supplier.get())
[ERROR] |               CHECKCAST com.google.common.base.Optional
[ERROR] |               ASTORE_2
[ERROR] |               ALOAD_2     // Lcom/google/common/base/Optional; optRootNode   (line 30)
[ERROR] | method-call(boolean com.google.common.base.Optional.isPresent())
[ERROR] | |             INVOKEVIRTUAL com.google.common.base.Optional.isPresent ()Z
[ERROR] | method-call(boolean com.google.common.base.Optional.isPresent())
[ERROR] |               IFEQ L0
[ERROR] |               ALOAD_0     // Lcom/company/project/view/evaluation/EvaluationTagTreeInitTask; this   (line 32)
[ERROR] | field-get(java.util.List com.company.project.view.evaluation.EvaluationTagTreeInitTask.rootNodes)
[ERROR] | |             GETFIELD com.company.project.view.evaluation.EvaluationTagTreeInitTask.rootNodes Ljava/util/List;
[ERROR] | field-get(java.util.List com.company.project.view.evaluation.EvaluationTagTreeInitTask.rootNodes)
[ERROR] | method-call(void java.util.List.clear())
[ERROR] | |             INVOKEINTERFACE java.util.List.clear ()V
[ERROR] | method-call(void java.util.List.clear())
[ERROR] |               ALOAD_2     // Lcom/google/common/base/Optional; optRootNode   (line 33)
[ERROR] | method-call(java.lang.Object com.google.common.base.Optional.get())
[ERROR] | |             INVOKEVIRTUAL com.google.common.base.Optional.get ()Ljava/lang/Object;
[ERROR] | method-call(java.lang.Object com.google.common.base.Optional.get())
[ERROR] |               CHECKCAST com.company.project.view.tree.EvalTreeInputNode
[ERROR] |               ASTORE_3
[ERROR] |               ALOAD_3     // Lcom/company/project/view/tree/EvalTreeInputNode; rootNode   (line 34)
[ERROR] | method-call(void com.company.project.view.tree.EvalTreeInputNode.selectNode())
[ERROR] | |             INVOKEINTERFACE com.company.project.view.tree.EvalTreeInputNode.selectNode ()V
[ERROR] | method-call(void com.company.project.view.tree.EvalTreeInputNode.selectNode())
[ERROR] |               ALOAD_0     // Lcom/company/project/view/evaluation/EvaluationTagTreeInitTask; this   (line 35)
[ERROR] |               GETFIELD com.company.project.view.evaluation.EvaluationTagTreeInitTask.rootNodes Ljava/util/List;
[ERROR] |               ALOAD_3     // Lcom/company/project/view/tree/EvalTreeInputNode; rootNode
[ERROR] |               INVOKEINTERFACE java.util.List.add (Ljava/lang/Object;)Z
[ERROR] |               POP
[ERROR] |           L0: RETURN   (line 38)
[ERROR] method-execution(void com.company.project.view.evaluation.EvaluationTagTreeInitTask.execute(com.company.project.time.Time))
[ERROR] end public void execute(com.company.project.time.Time) throws java.lang.Exception
[ERROR] 
[ERROR] end public class com.company.project.view.evaluation.EvaluationTagTreeInitTask
[ERROR] -- (StackOverflowError) null
[ERROR] null
[ERROR] java.lang.StackOverflowError
[ERROR] at java.util.WeakHashMap.hash(WeakHashMap.java:298)
[ERROR] at java.util.WeakHashMap.get(WeakHashMap.java:396)
[ERROR] at java.util.Collections$SynchronizedMap.get(Collections.java:2584)
[ERROR] at org.aspectj.weaver.World$TypeMap.get(World.java:1302)
[ERROR] at org.aspectj.weaver.World.resolve(World.java:296)
[ERROR] at org.aspectj.weaver.World.resolve(World.java:228)
[ERROR] at org.aspectj.weaver.UnresolvedType.resolve(UnresolvedType.java:615)
[ERROR] at org.aspectj.weaver.ResolvedType.getRawType(ResolvedType.java:2444)
[ERROR] at org.aspectj.weaver.ReferenceType.isAssignableFrom(ReferenceType.java:496)
[ERROR] at org.aspectj.weaver.ReferenceType.isAssignableFrom(ReferenceType.java:454)
[ERROR] at org.aspectj.weaver.TypeVariable.isASubtypeOf(TypeVariable.java:201)
[ERROR] at org.aspectj.weaver.TypeVariable.canBeBoundTo(TypeVariable.java:191)
[ERROR] at org.aspectj.weaver.ReferenceType.isAssignableFrom(ReferenceType.java:566)
[ERROR] at org.aspectj.weaver.ReferenceType.isAssignableFrom(ReferenceType.java:454)
[ERROR] at org.aspectj.weaver.ReferenceType.isAssignableFrom(ReferenceType.java:615)
[ERROR] at org.aspectj.weaver.ReferenceType.isAssignableFrom(ReferenceType.java:454)
[ERROR] at org.aspectj.weaver.TypeVariable.isASubtypeOf(TypeVariable.java:201)
[ERROR] at org.aspectj.weaver.TypeVariable.canBeBoundTo(TypeVariable.java:191)
[ERROR] at org.aspectj.weaver.ReferenceType.isAssignableFrom(ReferenceType.java:566)

最后6行重复几十次,直到堆栈跟踪结束。 maven构建似乎进入递归循环,直到发生堆栈溢出。

1 个答案:

答案 0 :(得分:1)

你有一个创建目录循环的符号链接,你有一个插件可以遍历所有类进行修改(这里可能是aspectj-maven-plugin)。该插件可能正在使用一些递归算法来遍历目录,因此由于目录循环(使其看起来有无数个目录),它将达到堆栈溢出。

执行cp -r时,您不会保留符号链接,这就是为什么要修复它,但cp -acp -rp都会保留链接,你将继续失败。

您应该在项目中搜索符号链接,找到负责人并将其删除。