The xml-apis version 1.0xxx is referenced by multiple hibernate artifacts like hibernate-core, hibernate-entitymanager etc. It is annoying because it would conflict with the JRE’s own javax.xml api in the rt.jar which would cause problems like xml cannot parse.
We need to be extra careful about it since it usually is introduced thru transitive dependencies. Definitely manual exclude it from the known artifacts would help, but we can have a maven plugin to check for us: maven-enforcer-plugin
If we have similar config as below and have the xml-apis.jar in the dependency tree, the build will fail.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <version>1.4.1</version> <executions> <execution> <id>enforce-banned-dependencies</id> <goals> <goal>enforce</goal> </goals> <configuration> <rules> <bannedDependencies> <excludes> <!--this is to check we do not have the xml-apis included since JRE provides it already--> <exclude>xml-apis:xml-apis</exclude> </excludes> </bannedDependencies> </rules> <fail>true</fail> </configuration> </execution> </executions> </plugin>
Some other interesting discussion on this about maven’s nearest win policy.