Home >Java >javaTutorial >How to Escape \'Xerces Hell\' in Java/Maven?

How to Escape \'Xerces Hell\' in Java/Maven?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-19 05:55:02326browse

How to Escape

Dealing with "Xerces Hell" in Java/Maven?

Xerces, a widely used XML parser, has long been a source of frustration for Java developers due to its history of unversioned JARs, lack of official Maven releases, and split jars (xml-apis and xercesImpl). This has led to version conflicts and classloader issues.

Problems:

  • Conflict Resolution: When using enterprise software with repository proxies, multiple versions of Xerces (e.g., xml-apis) from different organizations can be added as dependencies, leading to conflicts that Maven cannot resolve due to different groupIds.
  • Classloader Hell: The JRE includes Xerces as part of the JAXP implementation, but its version may not be compatible with that used by third-party libraries or servlet containers. This can cause classloading issues at runtime.

Solutions:

While marking Xerces dependencies as or can help, it's difficult to enforce and may not be compatible with all frameworks/libraries.

Maven Central Resolution:

In February 2013, JARs for Xerces 2.11.0 and its source JARs were released on Maven Central. This eliminates the need for custom builds and simplifies dependency management.

To use the Maven Central version:

<dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.11.0</version>
</dependency>

Future Improvements:

The Apache Xerces team has uploaded patched build scripts that allow for automated Maven Central upload, addressing the root cause of the "Xerces hell." This improvement should resolve the issues permanently.

The above is the detailed content of How to Escape \'Xerces Hell\' in Java/Maven?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn