title: .ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory
body: <p>I am upgrading Weblogic server from 9 to 10.3.6. when I am trying to deploy my ear application and got below exception. </p>
  
  <pre><code>Caused By: java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory
      at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:123)
      at org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:89)
      at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
      at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:113)
      at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:80)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353)
      at org.springframework.context.access.ContextSingletonBeanFactoryLocator.initializeDefinition(ContextSingletonBeanFactoryLocator.java:141)
      at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:384)
      at org.springframework.web.context.ContextLoader.loadParentContext(ContextLoader.java:341)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:195)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
      at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
      at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:181)
      at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1868)
  </code></pre>
  
  <p>I tried all sorts for things including adding a weblogic-application.xml but it still does not work.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
     &lt;weblogic-application&gt;
   &lt;xml&gt;
   &lt;parser-factory&gt;
      &lt;saxparser-factory&gt;
        org.apache.xerces.jaxp.SAXParserFactoryImpl
      &lt;/saxparser-factory&gt;
      &lt;document-builder-factory&gt;
        org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
      &lt;/document-builder-factory&gt;
      &lt;transformer-factory&gt;
        org.apache.xalan.processor.TransformerFactoryImpl
      &lt;/transformer-factory&gt;
    &lt;/parser-factory&gt;
  &lt;/xml&gt;
  
  &lt;prefer-application-packages&gt;
   &lt;package-name&gt;org.apache.xerces.parsers.*&lt;/package-name&gt;
  &lt;/prefer-application-packages&gt;
  &lt;/weblogic-application&gt;
  </code></pre>
  
  <p>my weblogic.xml has</p>
  
  <pre><code>&lt;prefer-web-inf-classes&gt;true&lt;/prefer-web-inf-classes&gt;
  </code></pre>
  
  <p>This is part of my pom.xml:</p>
  
  <pre><code>&lt;dependency&gt;
  &lt;groupId&gt;xerces&lt;/groupId&gt;
  &lt;artifactId&gt;xercesImpl&lt;/artifactId&gt;
  &lt;version&gt;2.8.1&lt;/version&gt;
  &lt;scope&gt;runtime&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Please help. Thanks!</p>