title: java.lang.ClassCastException: org.apache.xerces.parsers.SAXParser cannot be cast to org.xml.sax.XMLReader Hibernate
body: <p>I am working on a project with Hibernate <code>JPA</code> /<code>spring</code>. </p>
  
  <p>It throws the following exception. After doing some reading I removed all the xml-apis from dependencies but it throws the same error. Any ideas ??</p>
  
  <pre><code>java.lang.ClassCastException: org.apache.xerces.parsers.SAXParser cannot be cast to org.xml.sax.XMLReader
      at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:199)
      at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:150)
      at org.dom4j.io.SAXHelper.createXMLReader(SAXHelper.java:83)
      at org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:894)
      at org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:715)
      at org.dom4j.io.SAXReader.setFeature(SAXReader.java:218)
      at org.hibernate.internal.util.xml.MappingReader.setValidationFor(MappingReader.java:114)
      at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:77)
      at org.hibernate.cfg.Configuration.add(Configuration.java:478)
      at org.hibernate.cfg.Configuration.add(Configuration.java:474)
      at org.hibernate.cfg.Configuration.add(Configuration.java:647)
      at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:685)
      at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:1248)
      at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1048)
      at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:693)
      at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
      at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
      at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
  </code></pre>
  
  <p>while I am trying to initialise the web context in jetty web server it throw the above exception.[Spring (3.0.6.Release) &amp; hibernate (4.1.10.final) ]</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:util="http://www.springframework.org/schema/util"
     xmlns:context="http://www.springframework.org/schema/context"
     xmlns:tx="http://www.springframework.org/schema/tx"
     xmlns:p="http://www.springframework.org/schema/p"
     xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-3.0.xsd
         http://www.springframework.org/schema/tx
         http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"&gt;
  
  &lt;import resource="classpath*:/META-INF/spring-orchestra-init.xml"/&gt;
  
  &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
          &lt;/bean&gt;
  
  &lt;bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/&gt;
  
  &lt;bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/&gt;
  
  &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;
  
  &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"    
        p:persistenceUnitName="persistenceUnit"&gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
      &lt;property name="jpaDialect"&gt;
          &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/&gt;
      &lt;/property&gt;
      &lt;property name="jpaVendorAdapter"&gt;
          &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
              &lt;property name="showSql" value="true"/&gt;
              &lt;property name="generateDdl" value="false"/&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
      &lt;property name="loadTimeWeaver"&gt;
          &lt;bean class="org.faces.controller.jpa.JpaLoadTimeWeaver"/&gt;
      &lt;/property&gt;
  
  &lt;/bean&gt;
  
  &lt;bean class="org.springframework.beans.factory.config.CustomScopeConfigurer"&gt;
      &lt;property name="scopes"&gt;
          &lt;map&gt;
              &lt;entry key="conversation.access"&gt;
                  &lt;bean class="org.apache.myfaces.orchestra.conversation.spring.SpringConversationScope"&gt;
                      &lt;property name="advices"&gt;
                          &lt;list&gt;
                              &lt;ref bean="persistentContextConversationInterceptor" /&gt;
                          &lt;/list&gt;
                      &lt;/property&gt;
                  &lt;/bean&gt;
              &lt;/entry&gt;
          &lt;/map&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jpaPersistentContextFactory" class="org.apache.myfaces.orchestra.conversation.spring.JpaPersistenceContextFactory"&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
  &lt;/bean&gt;
  &lt;bean id="persistentContextConversationInterceptor" class="org.apache.myfaces.orchestra.conversation.spring.PersistenceContextConversationInterceptor"&gt;
      &lt;property name="persistenceContextFactory" ref="jpaPersistentContextFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;bean name="org.apache.myfaces.orchestra.conversation.AccessScopeManagerConfiguration"
        class="org.apache.myfaces.orchestra.conversation.AccessScopeManagerConfiguration"
        scope="singleton" lazy-init="true"&gt;
  
      &lt;property name="ignoreViewIds"&gt;
          &lt;set&gt;
              &lt;value&gt;/__ADFv__.xhtml&lt;/value&gt;
          &lt;/set&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  &lt;bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
      &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /&gt;
      &lt;property name="url" value="jdbc:oracle:thin:@rum:1541:CHEZTST" /&gt;
      &lt;property name="username" value="username" /&gt;
      &lt;property name="password" value="password" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>