相关文章推荐
谦逊的毛豆  ·  cmd move命令 ...·  8 月前    · 
灰常酷的鸡蛋  ·  Vue + ...·  1 年前    · 
英勇无比的双杠  ·  Android || ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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

Ask Question

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" ?

The reason is because we are using Alfresco 3.4, which is using CXF 2.2.2, which we needed to patch. So I had to compile the sources of CXF 2.2.2 with minimal changes. And the pom.xml of CXF 2.2.2 is using maven-shade-plugin 1.2. In the end I had to upgrade at least the maven-shade-plugin, to the minimal version which works, and that is 1.3.1 :) – Sorin Postelnicu Sep 6, 2015 at 11:59 And I know, Alfresco 3.4 is also extremely ancient, but a migration of our project to a newer Alfresco version requires a lot of work. (We have started doing it, but we still need new features to work, such as calling some web services with Apache CXF, and we need them long before finishing the Alfresco upgrade..) – Sorin Postelnicu Sep 6, 2015 at 12:02

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.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.