执行org.apache.maven.plugins时遇到API不兼容:maven-shade-plugin:1.3.1:shade:java.lang.AbstractMethodError:null

时间:2015-09-03 17:57:11

标签: java maven cxf maven-shade-plugin

在尝试构建旧版本的Apache CXF 2.2.2时,我不断收到由 maven-shade-plugin 使用的 XmlAppendingTransformer 产生的错误:无法连接以获取http://java.sun.com/dtd/properties.dtd的DTD(由文件 META-INF / cxf / extensions.xml 引用)

我尝试使用maven-shade-plugin从版本1.3.1开始提供的 ignoreDtd 选项来解决此问题。

但现在我又遇到了另一个奇怪的错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:1.3.1:shade (default) on project cxf-bundle: Execution default of goal org.apache.maven.plugins:maven-shade-plugin:1.3.1:shade failed: An API incompatibility was encountered while executing org.apache.maven.plugins:maven-shade-plugin:1.3.1:shade: java.lang.AbstractMethodError: null
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.maven.plugins:maven-shade-plugin:1.3.1
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/postese/.m2/repository/org/apache/maven/plugins/maven-shade-plugin/1.3.1/maven-shade-plugin-1.3.1.jar
[ERROR] urls[1] = file:/C:/Users/postese/libraries/apache-cxf-2.2.2-patched-src/buildtools/target/cxf-buildtools-2.2.2.jar
[ERROR] urls[2] = file:/C:/Users/postese/.m2/repository/pmd/pmd/4.2/pmd-4.2.jar
[ERROR] urls[3] = file:/C:/Users/postese/.m2/repository/ant/ant/1.6/ant-1.6.jar
[ERROR] urls[4] = file:/C:/Users/postese/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] urls[5] = file:/C:/Users/postese/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.5/plexus-utils-1.5.5.jar
[ERROR] urls[6] = file:/C:/Users/postese/.m2/repository/asm/asm/3.2/asm-3.2.jar
[ERROR] urls[7] = file:/C:/Users/postese/.m2/repository/asm/asm-commons/3.2/asm-commons-3.2.jar
[ERROR] urls[8] = file:/C:/Users/postese/.m2/repository/asm/asm-tree/3.2/asm-tree-3.2.jar
[ERROR] urls[9] = file:/C:/Users/postese/.m2/repository/org/jdom/jdom/1.1/jdom-1.1.jar
[ERROR] urls[10] = file:/C:/Users/postese/.m2/repository/org/apache/maven/shared/maven-dependency-tree/1.1/maven-dependency-tree-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[project>org.apache.cxf:cxf-bundle:2.2.2, parent: ClassRealm[maven.api, parent: null]]]
[ERROR]
[ERROR] -----------------------------------------------------

哪个库或插件导致" API不兼容" ?

1 个答案:

答案 0 :(得分:1)

在经过大量挖掘并尝试逐一消除 maven-shade-plugin 使用的 ResourceTransformers 之后,我找到了罪魁祸首:

显然现在问题不是由XmlAppendingTransformer引起的,但Apache CXF定义了两个ResourceTransformers:

apache-cxf-2.2.2-patched-src\buildtools\src\main\java\org\apache\cxf\maven:

CXFAllTransformer.java
PluginTransformer.java

在CXF 2.2.2 中定义的两个变换器与maven-shade-plugin 版本1.3中定义的新 ResourceTransformer接口不兼容。 1 ,因为缺少这种新方法:

public void processResource(String resource, InputStream is, List relocators) throws IOException {

他们已被修复"在CXF 2.2.12中,它们包括这种方法。

所以我的#34;修复"是将这两个变换器的源代码从CXF 2.2.12的源代码复制到" patched" CXF 2.2.2的源代码。