exclude xml-apis dependency in maven

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.

                              <!--this is to check we do not have the xml-apis included since JRE provides it already-->

Some other interesting discussion on this about maven’s nearest win policy.


One comment

  1. Shawn McKinney · September 16

    This little article saved me a ton of trouble. Thanks for putting it out there.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s