hibernate entitymanager spring BeanDefinitionStoreException FactoryConfigurationError DocumentBuilderFactory cannot be found

When we try to upgrade spring jpa/hibernate from 3 to 4. One of our standalone jar using spring has error when loading application context:

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring/application-context-xxx.xml]; nested exception is javax.xml.parsers.FactoryConfigurationError: Provider for javax.xml.parsers.DocumentBuilderFactory cannot be found

 

After searching around, it turns out the hibernate-entitymanager 4.3.11 has a dependency on jdom which has a dependency on xml-apis which will conflict with the JRE’s rt.jar’s javax.xml stuff. We exclude it so that our spring xml config could be correctly parsed.

To solve the problem, we can just exclude the xml-apis from the dependency tree.

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <exclusions>
                <!--the hibernate-entitymanager 4.3 has a dependency on jdom which has a dependency on xml-apis which will conflict with
                    the JRE's rt.jar's javax.xml stuff. We exclude it so that our spring xml config could be correctly parsed.-->
                <exclusion>
                    <groupId>xml-apis</groupId>
                    <artifactId>xml-apis</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

 

 

 

Advertisements

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