1 2 Previous Next 15 Replies Latest reply on May 22, 2015 3:17 PM by sanjay05222

    NoClassDefFoundError: org/apache/xerces/parsers/DOMParser


      I am getting javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/xerces/parsers/DOMParser

      I am using Wildfy8.2.0 which use DOM parser from org.apache.xerces module.


      If i inlcude xercesImpl-2.9.1-jbossas-2.jar in WEB-INF/lib than it throws java.lang.LinkageError: loader constraint violation: when resolving overridden method "org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Lorg/xml/sax/InputSource;)Lorg/w3c/dom/Document;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/apache/xerces/jaxp/DocumentBuilderImpl, and its superclass loader (instance of <bootloader>), have different Class objects for the type org/w3c/dom/Document used in the signature


      How do I fix it.



        • 1. Re: NoClassDefFoundError: org/apache/xerces/parsers/DOMParser

          what does your WEB-INF/lib contain?

          • 2. Re: NoClassDefFoundError: org/apache/xerces/parsers/DOMParser


            • 3. Re: NoClassDefFoundError: org/apache/xerces/parsers/DOMParser

              Have you added the org.apache.xerces module to either you manifest as a dependency or jboss-deployment-structure.xml (see Class Loading in WildFly - WildFly 8 - Project Documentation Editor) . I would try that and see what happens rather than adding it to your deployment.  I am a believer in utillizing the jboss modules - create your own layer - rather than having a bunch of libraries in your deployment.  Especially some I see that will conflict with those inthe WildFly container (I.e. servlet, app servers already supply a servlet engine, don't try to add your own library as it may conflict).


              If you still get errors after adding the xerces module, it will most likely not be not found, but rather showing where there is a conflict in versions between what WildFly supplies and one of the libraries in your deployment. 

              • 4. Re: NoClassDefFoundError: org/apache/xerces/parsers/DOMParser

                I think you should use xercesImpl not the Jboss one , just incase if you want to use xercesImpl-2.9.1-jbossas-2.jar , You can do so by putting inside your Jboss-deployment-structure the module as dependency.

                I think JBoss new class loader is some how in many ways is still a pain and things dont work as anticipated or described in the documentation. I want to volunteer for  writing and updating class loading document but I dont have much details unless I dig into the code.

                but if contributors on forum can write a thumb rule based document it will be awesome.

                There had been class loading strategy earlier that first the any class required will be loaded it will be done from Parent Class loader and then it will search locally inside the lib of war . I see this was in WebLogic and Wepsphere earlier. But in the current Modular Class loading , I have seen lots of issues when we have a module configured and also have same jar inside out lib . Its kind of decides own it owns.

                My Question is can there be a flow chart which can assure that if we package things in certain way we will not have issue like above ?

                I had lot of issues while configuring the Camel Wildfly where camel patch uses spring framework and it uses web and context libraries but my camel application war file also used the spring framework and it will happen that even if I pack all the spring dependencies inside the war and deploy it inside the widlfly-camel patch release wildfly instance it was not able to resolve some of the classes between the wildfly-camel modules spring and the spring jars which were inside my war.  that is still not resolved for me .. but I am still experimenting what will work and what will not but if contributers can and know the how exactly the class loader in Jboss is works and they can provide details in form of documentation it will be great help for most of the issues which is faced by user community.


                • 5. Re: NoClassDefFoundError: org/apache/xerces/parsers/DOMParser

                  Hi Matt,


                  I have added jboss-deployment-structure.xml file in META-INF of EAR file, Is it right place to add it.


                  Here is the content of file. No matter whatever I add / remove in this file its not making any difference.

                  Is anything wrong with it/ do I need to set reference for this file somewhere else (standalone.xml or ?).


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




                                <module name="javax.servlet.jsp.api" />



                                <module name="org.apache.xerces" />






                  • 6. Re: NoClassDefFoundError: org/apache/xerces/parsers/DOMParser

                    for start remove





                    from your web-inf lib, you will have much less problems...

                    • 7. Re: NoClassDefFoundError: org/apache/xerces/parsers/DOMParser

                      I removed both of these JARs and got error,


                      Line 364, column 32: error: package javax.servlet.http does not exist


                      Looks like its not recognizing servlet classes.



                      • 8. Re: NoClassDefFoundError: org/apache/xerces/parsers/DOMParser

                        I am guessing you have an ear with a war sub-deployment?  I think since you want this to apply to the war you will want to have it in your web-inf of the war file rather than the meta-inf of the ear. If leaving in the meta-inf you may want to try setting ear sub deployments explicitly to false.  I am also not sure why you are excluding the jsp api? 

                        • 9. Re: NoClassDefFoundError: org/apache/xerces/parsers/DOMParser

                          yes, becouse you have


                                        <module name="javax.servlet.jsp.api" />



                          remove that as well.

                          • 10. Re: NoClassDefFoundError: org/apache/xerces/parsers/DOMParser

                            I created module.xml


                            <module xmlns="urn:jboss:module:1.1" name="gov.cdc.nedss">



                                    <resource-root path="dom.jar"/>

                                    <resource-root path="jakarta-bcel-20040329.jar"/>

                                    <resource-root path="jakarta-regexp-1.4.jar"/>

                                    <resource-root path="resolver.jar"/>

                                    <resource-root path="xalan-2.7.0.jar"/>

                                    <resource-root path="xsltc.jar"/>

                                    <resource-root path="castor-"/>

                                    <resource-root path="log4j.jar"/>

                                    <resource-root path="commons-pool-1.2.jar"/>

                                    <resource-root path="commons-collections-3.2.jar"/>

                                    <resource-root path="cdf-subform.jar"/>

                                    <resource-root path="jaxb-api.jar"/>

                                    <resource-root path="jaxb-impl.jar"/>

                                    <resource-root path="jaxb-libs.jar"/>

                                    <resource-root path="jaxb-xjc.jar"/>

                                    <resource-root path="jax-qname.jar"/>

                                    <resource-root path="namespace.jar"/>

                                    <resource-root path="relaxngDatatype.jar"/>

                                    <resource-root path="xsdlib.jar"/>

                                    <resource-root path="commons-logging-1.0.4.jar"/>

                                    <resource-root path="struts-core-1.3.8.jar"/>

                                    <resource-root path="struts-el-1.3.8.jar"/>

                                    <resource-root path="struts-extras-1.3.8.jar"/>

                                    <resource-root path="struts-faces-1.3.8.jar"/>

                                    <resource-root path="struts-taglib-1.3.8.jar"/>

                                    <resource-root path="jstl-1.0.2.jar"/>

                                    <resource-root path="commons-beanutils-1.7.0.jar"/>

                                    <resource-root path="commons-digester-1.8.jar"/>

                                    <resource-root path="commons-chain-1.1.jar"/>

                                    <resource-root path="commons-validator-1.3.1.jar"/>

                                    <resource-root path="Struts-Layout-1.2.jar"/>

                                    <resource-root path="oro-2.0.8.jar"/>

                                    <resource-root path="ditchnet-tabs-taglib.jar"/>

                                    <resource-root path="JustFormsPDF.jar"/>

                                    <resource-root path="xbean-2.3.0.jar"/>

                                    <resource-root path="jsr173_1.0_api.jar"/>

                                    <resource-root path="xbean_xpath.jar"/>

                                    <resource-root path="xmlbeans-qname.jar"/>

                                    <resource-root path="xmlpublic.jar"/>

                                    <resource-root path="mail.jar"/>

                                    <resource-root path="activation.jar"/>

                                    <resource-root path="PHDCMessage.jar"/>

                                    <resource-root path="CDAMessage.jar"/>

                                    <resource-root path="jcommon-1.0.16.jar"/>

                                    <resource-root path="commons-fileupload-1.1.1.jar"/>

                                    <resource-root path="commons-codec-1.4.jar"/>

                                    <resource-root path="commons-io-1.1.jar"/>

                                    <resource-root path="jfreechart-1.0.13.jar"/>

                                    <resource-root path="nbs-charts.jar"/>

                                    <resource-root path="hessian-3.1.3.jar"/>

                                    <resource-root path="vocabServiceClient.jar"/>

                                    <resource-root path="dmbPageSchema.jar"/>

                                    <resource-root path="dmbTemplateExportSchema.jar"/>

                                    <resource-root path="DSMAlgorithm.jar"/>

                                    <resource-root path="pdfbox-app-1.8.2.jar"/>

                                    <resource-root path="sqljdbc4.jar"/>

                                    <resource-root path="concurrent-1.3.4.jar"/>

                                    <resource-root path="tools.jar"/>

                                    <!-- Insert resources here -->



                                    <module name="javax.api"/>

                                    <module name="javax.transaction.api"/>

                                    <module name="javax.servlet.api"/>

                                    <module name="org.apache.xerces"/>

                                    <module name="javax.servlet.jsp.api"/>

                                    <module name="javax.servlet.jstl.api"/>

                                    <module name="io.undertow.jsp"/>




                            Which I am referring in <global-modules> in standalone.xml,


                            WEB-INF/lib has servlet-2.3.jar thats why I am excluding javax.servlet.jsp.api in jboss-deployment-structure.



                            • 11. Re: NoClassDefFoundError: org/apache/xerces/parsers/DOMParser

                              D P wrote:


                              I created module.xml


                              <module xmlns="urn:jboss:module:1.1" name="gov.cdc.nedss">



                                     <resource-root path="tools.jar"/>

                                      <!-- Insert resources here -->





                              I sincerely hope this is not JDK's tools.jar,

                              but beyond that, seeing what you are doing and not understanding what it means and why most of stuff you are trying do is really wrong, I wish you good luck with your endeavors.

                              • 12. Re: NoClassDefFoundError: org/apache/xerces/parsers/DOMParser

                                Hi DP


                                I think you have to be more informative in terms of whether there is a ear inside the war or what exactly . give more information in terms of for example I have a ear and also have war, my application using following framework etc etc. so in that way we can help to get to the point.

                                to me looks like that now you are trying to take out all the lib from the web-inf and trying to create the module for your specifically trying to put all the jars out there so that in jboss-deployment you can put only one module which deploys all the jar and so that there is no class loading issues any more.


                                I think that should not be your approach .

                                First Plan : Jboss Deployment should have following things.

                                1. all the common jars or dependencies which are already their in the Jboss you should mentioned as dependencies and dont put them in the module which you are trying to create for your application.

                                  for example xerces , jaxb , tools.jar ( jdk related ) mention it as modules inside the deployment sturcutre  use all the jar modules. ( I hope i am able to communicate here )

                                2. ov.cdc.neds  put only the custom jars in here which are not supplied with the jboss modules.


                                If you do this you will not get conflicts.



                                Sanjay Gautam

                                • 13. Re: NoClassDefFoundError: org/apache/xerces/parsers/DOMParser

                                  Thanks Sanjay for reply.


                                  We have EAR file, which has WAR and EJB JAR file.

                                  WAR file's WEB-INF/lib has some dependency JARs and module.xml has resources JARs.


                                  Application uses Struts1.3 framework and EJB 1.1 specifications.



                                  • 14. Re: NoClassDefFoundError: org/apache/xerces/parsers/DOMParser

                                    It sounds like the real issue that you first need to deal with is getting compatible level technology in WildFly.  You will need to upgrade to EJB 3.0 at a min, and Struts 1.3 is EOL I am not sure it will be compatible with an EE7 compliant server.  To be honest I have not even tried.  You should think about moving off of struts to JSF to be more compliant moving forward with EE specifications.

                                    1 2 Previous Next