Xerces Parse Error with hadoop (or Solr): Feature ‘http://apache.org/xml/features/xinclude’ is not recognized.

Hadoop, when used programmatically has the nasty habit of getting messed up when reading it’s own config. The stack traces resemble this one:

 

Caused by: javax.xml.parsers.ParserConfigurationException: Feature ‘http://apache.org/xml/features/xinclude’ is not recognized.

at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)

at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:1889)

 

Or this:

 

Caused by: java.lang.RuntimeException: javax.xml.parsers.ParserConfigurationException: Feature ‘http://apache.org/xml/features/xinclude’ is not recognized.

at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2002)

at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:1851)

 

How to fix that:

1) make sure you have xerces and xalan within your classpath. If you use maven just add the following entries to your dependency section.

<dependency>

<groupId>xerces</groupId>

<artifactId>xercesImpl</artifactId>

<version>2.9.1</version>

</dependency>

<dependency>

<groupId>xalan</groupId>

<artifactId>xalan</artifactId>

<version>2.7.1</version>

</dependency>

2) make sure the JVM uses that parser instead of defaulting to the JDK parser. To do that, pass the following param to your VM:

-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

5 Responses to Xerces Parse Error with hadoop (or Solr): Feature ‘http://apache.org/xml/features/xinclude’ is not recognized.

  1. Bob says:

    Thanks so much! Very helpful!

  2. click here says:

    Do you mind if I quote a couple of your posts as long as I provide credit and sources
    back to your weblog? My blog site is in the exact same area of interest as
    yours and my visitors would genuinely benefit from a lot
    of the information you provide here. Please let me know if this ok with you.

    Thanks!

  3. David says:

    You saved my day, thank you!

  4. liubaolongcool says:

    my god ,it’s ok

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s