Search code examples
javamaventomcatxerces

Apache Tomcat failed to start with SAXParserFactoryImpl not found


I'm trying to start Web application in Eclipse Apache Tomcat it failed with below error posted in gist.

Error:complete Error link

Caused by: java.lang.RuntimeException: Provider for class javax.xml.parsers.SAXParserFactory cannot be created
    at javax.xml.parsers.FactoryFinder.findServiceProvider(FactoryFinder.java:308)
    ... 38 more
Caused by: java.util.ServiceConfigurationError: javax.xml.parsers.SAXParserFactory: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
    at java.util.ServiceLoader.fail(ServiceLoader.java:239)

Below is pom file dependency related to xml , i have

 <dependency>
                            <groupId>xerces</groupId> 
                            <artifactId>xercesImpl</artifactId>
                            <version>2.4.0</version>
                            <scope>provided</scope>
                            </dependency>
                            <dependency>
                               <groupId>ibm</groupId>
                               <artifactId>xml4j</artifactId>
                                <version>2.0.15</version>
                         </dependency>

I tried various solutions , pasting xerces jar to jre/lib/endorsed folder , marking it as provided , refershing target directory nothing worked .


Solution

  • Since my comment helped you out, I'm posting it as an answer.

    Use Apache Xerces Dependency:

    <!-- https://mvnrepository.com/artifact/org.apache.xerces/xercesImpl -->
    <dependency>
        <groupId>org.apache.xerces</groupId>
        <artifactId>xercesImpl</artifactId>
        <version>2.9.1</version>
        <scope>runtime</scope>
    </dependency>