13 Replies Latest reply: Feb 4, 2013 12:27 PM by izan RSS

    org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to  javax.xml.parsers.DocumentBuilderFactory after removing xercesimpl.jar from WAR

    Anitha Kothandapani Newbie

      Hi

      I am using Jboss 5.1.0GA , Open Jdk 1.6

       

      I have xercesimpl.jar in my war. I got the following error during deployment

       

       

      Caused by: org.jboss.xb.binding.JBossXBException: Failed to create a new SAX parser
          at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.<init>(SaxJBossXBParser.java:97)
          at org.jboss.xb.binding.UnmarshallerImpl.<init>(UnmarshallerImpl.java:56)
          at org.jboss.xb.binding.UnmarshallerFactory$UnmarshallerFactoryImpl.newUnmarshaller(UnmarshallerFactory.java:96)
          ... 73 more
      Caused by: java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
          at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
          at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
      

       

      To resolve that I removed xercesimpl.jar from my war . But now I am getting the different error as given below

       

       

      2010-05-19 11:28:26,473 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/AdminWebApp]] (main) Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListener
      java.lang.ClassCastException: com.bluecast.xml.JAXPSAXParserFactory cannot be cast to javax.xml.parsers.SAXParserFactory
          at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:128)
          at com.sun.faces.config.ConfigureListener$WebXmlProcessor.getConfiguredFactory(ConfigureListener.java:698)
          at com.sun.faces.config.ConfigureListener$WebXmlProcessor.scanForFacesServlet(ConfigureListener.java:670)
          at com.sun.faces.config.ConfigureListener$WebXmlProcessor.<init>(ConfigureListener.java:644)
      2010-05-19 11:28:26,520 ERROR [STDERR] (main) javax.servlet.ServletException: java.lang.ClassCastException
      : org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFac
      tory
      2010-05-19 11:28:31,660 INFO  [STDOUT] (main) 11:28:31,660 ERROR  [ContextLoader] Context initialization failed
       org.springframework.beans.factory.BeanDefinitionStoreException:  Unexpected exception parsing XML document from ServletContext resource  [/WEB-INF/spring-conf/application-service.xml]; nested exception is  java.lang.ClassCastException:  org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to  javax.xml.parsers.DocumentBuilderFactory
           at  org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
           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.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
           at  org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
      

       

       

      Please help me to resolve this issue..

        • 1. Re: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to  javax.xml.parsers.DocumentBuilderFactory after removing xercesimpl.jar from WAR
          jaikiran pai Master

          Do you have any jar(s) containing  javax.xml.parsers.* classes in your application? If yes, remove those jars from your application packaging.

          • 2. Re: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to  javax.xml.parsers.DocumentBuilderFactory after removing xercesimpl.jar from WAR
            Anitha Kothandapani Newbie

            Thanks for your reply . yes. xml-apis.jar ,xmlbeans-qname.jar,piccolo.jar are the jars . Is it possible to resolve this issue without removing these jars.

             

            And even if I try by removing the three jars mentioned above  I get the following errors

             

             

             

            2010-05-19 14:43:57,514 ERROR [STDERR] (main) log4j:ERROR A "org.jboss.logging.appender.FileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
            2010-05-19 14:43:57,514 ERROR [STDERR] (main) log4j:ERROR The class "org.apache.log4j.Appender" was loaded by 
            2010-05-19 14:43:57,514 ERROR [STDERR] (main) log4j:ERROR [BaseClassLoader@178d35f{vfsfile:/C:/jboss-5.1.0.GA/server/default/deploy/AdminWebApp.war/}] whereas object of type
            2010-05-19 14:43:57,905 INFO  [STDOUT] (main) 14:43:57,874 ERROR [JaxBConfigurationManager] JAXB Exception occured while unmurshalling.
            javax.xml.bind.JAXBException
             - with linked exception:
            [java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "com.sun.xml.bind.DatatypeConverterImpl.parseQName(Ljava/lang/String;Ljavax/xml/namespace/NamespaceContext;)Ljavax/xml/namespace/QName;" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, com/sun/xml/bind/DatatypeConverterImpl, and the class loader (instance of <bootloader>) for interface javax/xml/bind/DatatypeConverterInterface have different Class objects for the type javax/xml/namespace/NamespaceContext used in the signature]
            
            • 3. Re: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to  javax.xml.parsers.DocumentBuilderFactory after removing xercesimpl.jar from WAR
              Anitha Kothandapani Newbie

              After seeing https://jira.jboss.org/browse/JBAS-7210 ,I understand that this seems to be a bug in Jboss 5.1.0 GA and it got fixed in jboss 6.0.0.M2  ,

               

              But I want to know whether I can fix this by applying any patch which is readily availble for Jboss 5.1.0 GA ?

              • 4. Re: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to  javax.xml.parsers.DocumentBuilderFactory after removing xercesimpl.jar from WAR
                jaikiran pai Master

                Anitha Kothandapani wrote:


                 

                But I want to know whether I can fix this by applying any patch which is readily availble for Jboss 5.1.0 GA ?

                You can checkout AS 5.1.0 from tag then apply the patch from here http://fisheye.jboss.org/rdiff/JBossAS?csid=97418&u&N and rebuild the AS.

                • 5. Re: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to  javax.xml.parsers.DocumentBuilderFactory after removing xercesimpl.jar from WAR
                  mike just Master

                  Hi jaikiran,

                   

                  Could you please confirm if this patch can also resolve this classcast exception?

                   

                  java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl cannot be cast to javax.xml.parsers.SAXParserFactory

                  • 7. Re: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to  javax.xml.parsers.DocumentBuilderFactory after removing xercesimpl.jar from WAR
                    mike just Master

                    Could you give me this binary patch based on 5.1.0 GA? I really do not know how to get the source code and do a re-build of 5.1.0. If you can do that for me or guide me how to do this, I will thank you really from my heart.

                    • 8. Re: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to  javax.xml.parsers.DocumentBuilderFactory after removing xercesimpl.jar from WAR
                      jaikiran pai Master

                      mike just wrote:

                       

                      I really do not know how to get the source code and do a re-build of 5.1.0. If you can do that for me or guide me how to do this

                      1) Checkout AS 5.1.0 from tag http://anonsvn.jboss.org/repos/jbossas/tags/JBoss_5_1_0_GA/
                      2) Build the AS as per the instructions here http://community.jboss.org/wiki/jbossasbuild (section JBossAS 5.x and Earlier versions)
                      3) Once the AS is built, just run it once to make sure everything  is fine.

                      4) Apply this patch http://fisheye.jboss.org/rdiff/JBossAS?csid=97418&u&N on the AS source code

                      5) Repeat step#2.

                       

                      If you have any problem building the server, please create a separate thread with the details.

                      • 9. Re: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to  javax.xml.parsers.DocumentBuilderFactory after removing xercesimpl.jar from WAR
                        maltiyadav Newbie

                        Hi Anitha,

                         

                        have u got any solution for the error,because i am also getting same issue.

                        Is applying patch solving the issue?

                        please let me know i am also stuck with same kind or error.

                         

                        Thanks.

                        • 11. Re: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to  javax.xml.parsers.DocumentBuilderFactory after removing xercesimpl.jar from WAR
                          erico mtx Newbie

                          Hello

                           

                          I am trying to run myfaces-example-simple20-1.1.11 in a JBoss 5.1.0 and have followed all the instructions from the links provided in the past replies but I am getting at this point so far :

                           

                           

                          Error: javax.faces.application.Application.createComponent(Ljavax/faces/context/FacesContext;Ljava/lang/String;Ljava/lang/String;)Ljavax/faces/component/UIComponent;

                           

                          I have tried several changes in the deployment descriptor and removing myfaces and el jar files from the project but none worked

                           

                          my web.xml is as follows :

                           

                          <?xml version="1.0" encoding="UTF-8"?>

                          <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

                            <description>debug web.xml</description>

                            <context-param>

                              <description>Comma separated list of URIs of (additional) faces config files.

                                      (e.g. /WEB-INF/my-config.xml)

                                      See JSF 1.0 PRD2, 10.3.2

                                      Attention: You do not need to put /WEB-INF/faces-config.xml in here.

                              </description>

                              <param-name>javax.faces.CONFIG_FILES</param-name>

                              <param-value>/WEB-INF/examples-config.xml,/WEB-INF/testSuite-config.xml</param-value>

                            </context-param>

                           

                            <context-param>

                              <description>State saving method: "client" or "server" (= default)

                                      See JSF Specification 2.5.3</description>

                              <param-name>javax.faces.STATE_SAVING_METHOD</param-name>

                              <param-value>server</param-value>

                            </context-param>

                           

                            <context-param>

                              <description>Only applicable if state saving method is "server" (= default).

                                      Defines the amount (default = 20) of the latest views are stored in session.</description>

                              <param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>

                              <param-value>20</param-value>

                            </context-param>

                           

                            <context-param>

                              <description>Only applicable if state saving method is "server" (= default).

                                      If true (default) the state will be serialized to a byte stream before it

                                      is written to the session.

                                      If false the state will not be serialized to a byte stream.</description>

                              <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>

                              <param-value>true</param-value>

                            </context-param>

                           

                            <context-param>

                              <description>Only applicable if state saving method is "server" (= default) and if

                                      org.apache.myfaces.SERIALIZE_STATE_IN_SESSION is true (= default)

                                      If true (default) the serialized state will be compressed before it

                                      is written to the session. If false the state will not be compressed.</description>

                              <param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>

                              <param-value>true</param-value>

                            </context-param>

                           

                            <context-param>

                              <description>This parameter tells MyFaces if javascript code should be allowed in the

                                      rendered HTML output.

                                      If javascript is allowed, command_link anchors will have javascript code

                                      that submits the corresponding form.

                                      If javascript is not allowed, the state saving info and nested parameters

                                      will be added as url parameters.

                                      Default: "true"</description>

                              <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>

                              <param-value>true</param-value>

                            </context-param>

                           

                            <context-param>

                              <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>

                              <param-value>false</param-value>

                            </context-param>

                           

                            <context-param>

                              <description>If true, rendered HTML code will be formatted, so that it is "human readable".

                                      i.e. additional line separators and whitespace will be written, that do not

                                      influence the HTML code.

                                      Default: "true"</description>

                              <param-name>org.apache.myfaces.PRETTY_HTML</param-name>

                              <param-value>true</param-value>

                            </context-param>

                           

                            <context-param>

                              <description>If true, a javascript function will be rendered that is able to restore the

                                      former vertical scroll on every request. Convenient feature if you have pages

                                      with long lists and you do not want the browser page to always jump to the top

                                      if you trigger a link or button action that stays on the same page.

                                      Default: "false"</description>

                              <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>

                              <param-value>true</param-value>

                            </context-param>

                           

                              <context-param>

                                    <description>

                                        Validate managed beans, navigation rules and ensure that forms are not nested.

                                    </description>

                                     <param-name>org.apache.myfaces.VALIDATE</param-name>

                                     <param-value>true</param-value>

                              </context-param>

                           

                            <context-param>

                              <description>A class implementing the

                                      org.apache.myfaces.shared.renderkit.html.util.AddResource

                                      interface. It is responsible to

                                         place scripts and css on the right position in your HTML document.

                                      Default: "org.apache.myfaces.shared.renderkit.html.util.DefaultAddResource"

                                      Follow the description on the MyFaces-Wiki-Performance page to enable

                                      StreamingAddResource instead of DefaultAddResource if you want to

                                      gain performance.

                              </description>

                              <param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>

                              <!-- param-value>org.apache.myfaces.renderkit.html.util.DefaultAddResource</param-value -->

                              <param-value>org.apache.myfaces.renderkit.html.util.NonBufferingAddResource</param-value>

                              <!--param-value>org.apache.myfaces.component.html.util.StreamingAddResource</param-value -->

                            </context-param>

                           

                           

                            <context-param>

                              <param-name>org.apache.myfaces.DISABLE_TOMAHAWK_FACES_CONTEXT_WRAPPER</param-name>

                              <param-value>false</param-value>

                            </context-param>

                           

                           

                            <context-param>

                              <description>

                                  A very common problem in configuring MyFaces-web-applications

                                  is that the Extensions-Filter is not configured at all

                                  or improperly configured. This parameter will check for a properly

                                  configured Extensions-Filter if it is needed by the web-app.

                                  In most cases this check will work just fine, there might be cases

                                  where an internal forward will bypass the Extensions-Filter and the check

                                  will not work. If this is the case, you can disable the check by setting

                                  this parameter to false.

                              </description>

                              <param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>

                              <param-value>true</param-value>

                            </context-param>

                             

                               <!-- JBossEL -->

                              <context-param>

                                  <param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>

                                  <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>

                              </context-param>

                             

                            <context-param>

                              <param-name>javax.faces.PROJECT_STAGE</param-name>

                              <param-value>Development</param-value>

                            </context-param>

                           

                            <context-param>

                              <param-name>org.apache.myfaces.USE_MULTIPLE_JS_FILES_FOR_JSF_UNCOMPRESSED_JS</param-name>

                              <param-value>true</param-value>

                            </context-param>

                           

                            

                            <context-param>

                              <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>

                              <param-value>true</param-value>

                            </context-param>

                           

                            <listener>

                              <listener-class>com.sun.faces.config.ConfigureListener</listener-class>

                            </listener>

                           

                            <filter>

                              <filter-name>extensionsFilter</filter-name>

                              <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>

                              <init-param>

                                <description>Set the size limit for uploaded files.

                                          Format: 10 - 10 bytes

                                                  10k - 10 KB

                                                  10m - 10 MB

                                                  1g - 1 GB</description>

                                <param-name>uploadMaxFileSize</param-name>

                                <param-value>100m</param-value>

                              </init-param>

                              <init-param>

                                <description>Set the threshold size - files

                                              below this limit are stored in memory, files above

                                              this limit are stored on disk.

                           

                                          Format: 10 - 10 bytes

                                                  10k - 10 KB

                                                  10m - 10 MB

                                                  1g - 1 GB</description>

                                <param-name>uploadThresholdSize</param-name>

                                <param-value>100k</param-value>

                              </init-param>

                            </filter>

                            <filter-mapping>

                              <filter-name>extensionsFilter</filter-name>

                              <url-pattern>*.jsf</url-pattern>

                            </filter-mapping>

                            <filter-mapping>

                              <filter-name>extensionsFilter</filter-name>

                              <url-pattern>/faces/*</url-pattern>

                            </filter-mapping>

                           

                           

                            <servlet>

                              <servlet-name>Faces Servlet</servlet-name>

                              <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

                              <load-on-startup>1</load-on-startup>

                            </servlet>

                           

                            <servlet>

                              <servlet-name>SourceCodeServlet</servlet-name>

                              <servlet-class>org.apache.myfaces.examples.webapp.SourceCodeServlet</servlet-class>

                            </servlet>

                           

                           

                            <servlet-mapping>

                              <servlet-name>Faces Servlet</servlet-name>

                              <url-pattern>*.jsf</url-pattern>

                            </servlet-mapping>

                           

                            <servlet-mapping>

                              <servlet-name>Faces Servlet</servlet-name>

                              <url-pattern>/faces/*</url-pattern>

                            </servlet-mapping>

                           

                            <servlet-mapping>

                              <servlet-name>SourceCodeServlet</servlet-name>

                              <url-pattern>*.source</url-pattern>

                            </servlet-mapping>

                           

                            <welcome-file-list>

                              <welcome-file>index.html</welcome-file>

                            </welcome-file-list>

                          </web-app>

                           

                          I have also created a jboss-classloading.xml in WEB-INF directory in my war file with the following content :

                           

                              <classloading xmlns="urn:jboss:classloading:1.0" 

                                            name="myfaces-example-simple20-1.1.11.war" 

                                            domain="localhost">

                              

                                            parent-domain="Ignored"

                               

                                            export-all="NON_EMPTY" 

                                            import-all="true"> 

                              </classloading>

                           

                          Can you guys help us out on this ?

                           

                          Thks

                          Érico

                          • 12. Re: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to  javax.xml.parsers.DocumentBuilderFactory after removing xercesimpl.jar from WAR
                            Uday Shankar Newbie

                            you need to ensure that you donot have any library in your war which contains package javax.xml.parsers; the jboss-classloading.xml you have created is in-correct.

                            • 13. Re: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to  javax.xml.parsers.DocumentBuilderFactory after removing xercesimpl.jar from WAR
                              izan Newbie

                              Hi,

                               

                              I've been trying to apply this patch to the tagged version, but it's nowhere to be found. Could you please point to it current location or how to obtain it?

                               

                              Appreciate it!