An API incompatibility was encountered while executing org.apache.maven.plugins:maven-shade-plugin:1.3.1:shade: java.lang.AbstractMethodError: null

有些话、适合烂在心里 提交于 2020-01-05 02:30:28

问题


While trying to build an old version of Apache CXF 2.2.2, I kept getting an error produced by an XmlAppendingTransformer used by the maven-shade-plugin: unable to connect to get the DTD for http://java.sun.com/dtd/properties.dtd (referenced by the file META-INF/cxf/extensions.xml)

I have tried to fix this problem by using the ignoreDtd option provided by maven-shade-plugin starting with version 1.3.1.

But now I am getting another more weird error:

[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] -----------------------------------------------------

Which library or plugin is causing the "API incompatibility" ?


回答1:


After a lot of digging and trying to eliminate one-by-one the ResourceTransformers used by the maven-shade-plugin, I have found the culprit:

Apparently now the problem was not caused by the XmlAppendingTransformer, but there are two ResourceTransformers defined by Apache CXF:

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

CXFAllTransformer.java
PluginTransformer.java

The two transformers as they were defined in CXF 2.2.2 are not compatible with the new ResourceTransformer interface defined in maven-shade-plugin version 1.3.1, because this new method is missing:

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

They have been "fixed" in CXF 2.2.12, where they include this method.

So my "fix" was to copy the source code of these 2 transformers from the source code of CXF 2.2.12 into the "patched" source code of CXF 2.2.2.



来源:https://stackoverflow.com/questions/32382445/an-api-incompatibility-was-encountered-while-executing-org-apache-maven-plugins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!