12 Replies Latest reply on Nov 25, 2011 3:15 PM by Barry Hathaway

    DVFactoryException during Spring bean creation

    Barry Hathaway Newbie

      When my service starts up and Spring tries to create and initialize the bean I get:

       

      DVFactoryException: DTD factory class org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl does not extend from DTDDVFactory.

       

      Any ideas?

      Thanks.

       

      Barry Hathaway

       

      --- full stack trace ---

      15:07:53,641 | ERROR | ExtenderThread-5 | ContextLoaderListener            | 85 - org.springframework.osgi.extender - 1.2.1 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=sadlserver-osgi-service, config=osgibundle:/META-INF/spring/*.xml))

      org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from URL bundleentry://232.fwk21616774/META-INF/spring/beans.xml; nested exception is org.apache.xerces.parsers.ObjectFactory$ConfigurationError: Provider org.apache.xerces.parsers.XIncludeAwareParserConfiguration could not be instantiated: org.apache.xerces.impl.dv.DVFactoryException: DTD factory class org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl does not extend from DTDDVFactory.

           at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)[68:org.springframework.beans:3.0.5.RELEASE]

           at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)[68:org.springframework.beans:3.0.5.RELEASE]

           at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)[68:org.springframework.beans:3.0.5.RELEASE]

           at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)[68:org.springframework.beans:3.0.5.RELEASE]

           at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)[68:org.springframework.beans:3.0.5.RELEASE]

           at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)[68:org.springframework.beans:3.0.5.RELEASE]

           at org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:164)[82:org.springframework.osgi.core:1.2.1]

           at org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:136)[82:org.springframework.osgi.core:1.2.1]

           at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)[70:org.springframework.context:3.0.5.RELEASE]

           at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)[70:org.springframework.context:3.0.5.RELEASE]

           at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$800(AbstractDelegatedExecutionApplicationContext.java:69)[82:org.springframework.osgi.core:1.2.1]

           at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$3.run(AbstractDelegatedExecutionApplicationContext.java:269)[82:org.springframework.osgi.core:1.2.1]

           at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[82:org.springframework.osgi.core:1.2.1]

           at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.startRefresh(AbstractDelegatedExecutionApplicationContext.java:247)[82:org.springframework.osgi.core:1.2.1]

           at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:214)[85:org.springframework.osgi.extender:1.2.1]

           at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:169)[85:org.springframework.osgi.extender:1.2.1]

           at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:175)[82:org.springframework.osgi.core:1.2.1]

           at org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:716)[85:org.springframework.osgi.extender:1.2.1]

           at java.lang.Thread.run(Thread.java:662)[:1.6.0_25]

      Caused by: org.apache.xerces.parsers.ObjectFactory$ConfigurationError: Provider org.apache.xerces.parsers.XIncludeAwareParserConfiguration could not be instantiated: org.apache.xerces.impl.dv.DVFactoryException: DTD factory class org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl does not extend from DTDDVFactory.

           at org.apache.xerces.parsers.ObjectFactory.newInstance(Unknown Source)[:]

           at org.apache.xerces.parsers.ObjectFactory.createObject(Unknown Source)[:]

           at org.apache.xerces.parsers.ObjectFactory.createObject(Unknown Source)[:]

           at org.apache.xerces.parsers.DOMParser.(Unknown Source)[:]

           at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(Unknown Source)[:]

           at org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:99)

           at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70)

           at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)

           ... 18 more

        • 1. Re: DVFactoryException during Spring bean creation
          Freeman(Yue) Fang Master

          Hi,

           

          This generally means DTDDVFactoryImpl and DTDDVFactory are loaded by different classloader.

           

          If your customer bundle embed some 3rd party lib, you can usually encounter this kind of issue. In OSGi world embed jar isn't a good practice, you should import all necessary package from the bundles installed in OSGi container.

           

          So if your customer bundle have embeded jars, try to remove them and install them as bundle if necessary.

           

          Freeman

          • 2. Re: DVFactoryException during Spring bean creation
            Barry Hathaway Newbie

            I'm finally getting back to this and trying to resolve it.

            I have carefully checked all the bundle imports and exports and all seem OK.

            I'm still getting the error mentioned when spring creates and tries to initialize the bean.

            In an attempt to narrow the problem down I build a simple bundle and tried to instantiate

            and initialize the bean.  In the start method I put:

             

                 ISadlServiceProvider ss = new SadlServiceProvider();

                 ss.setKbaseRoot("D:
            projects
            SADL
            SadlServerV2Standalone
            DataModels");

             

            where SadlServiceProvider is the name of my CXF service (in a separate bundle).

            The bundle starts without generating any errors.  It is only when  Spring starts the

            bundle do I see the DVFactoryException errors.

            Any ideas where to look next?

            Thanks.

            • 3. Re: DVFactoryException during Spring bean creation
              Freeman(Yue) Fang Master

              Hi,

               

              What do you mean by

              "The bundle starts without generating any errors. It is only when Spring starts the

              bundle do I see the DVFactoryException errors?"

               

              Btw, I think you should first check if your bundle embed any third party jars, also what's exactly FUSE ESB version you're using?

              Could you test with the FUSE ESB latest release to see if the error still there?

               

              Freeman

              • 4. Re: DVFactoryException during Spring bean creation
                Barry Hathaway Newbie

                >> What do you mean by

                >> "The bundle starts without generating any errors. It is only when Spring starts the

                >> bundle do I see the DVFactoryException errors?"

                 

                The bundle in question implements a CXF web service. It is defined/annotated as:

                 

                @WebService(serviceName="SadlService",name="SadlService",targetNamespace="http://sadlserver.sadl.research.ge.com",endpointInterface="com.ge.research.sadl.sadlserver.cxf.provider.ISadlServiceProvider")

                public class SadlServiceProvider implements ISadlServiceProvider {

                 

                Its bean definition is:

                 

                Could you test with the FUSE ESB latest release to see if the error still there?

                 

                I'm willing to try it with any snapshots that are out there.

                 

                Thanks.

                Barry

                • 5. Re: DVFactoryException during Spring bean creation
                  Barry Hathaway Newbie

                  Freeman,

                   

                  I did upgrade to apache-servicemix-4.4.1-fuse-01-06 and I'm getting probably a more

                  descriptive error:

                   

                  Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:

                  PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'kbaseRoot' threw exception; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.xerces.parsers.SAXParser.) for resolved class, org/apache/xerces/parsers/SAXParser, have different Class objects for the type org/apache/xerces/xni/parser/XMLParserConfiguration used in the signature

                       at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)[67:org.springframework.beans:3.0.5.RELEASE]

                       at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)[67:org.springframework.beans:3.0.5.RELEASE]

                       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1358)[67:org.springframework.beans:3.0.5.RELEASE]

                       ... 25 more

                  • 6. Re: DVFactoryException during Spring bean creation
                    Freeman(Yue) Fang Master

                    Hi,

                     

                    What's your whole beans.xml looks like?

                    Is it possible that you can append a simple testcase(source project) which we can build and deploy to reproduce this issue?

                     

                    Freeman

                    • 7. Re: DVFactoryException during Spring bean creation
                      Barry Hathaway Newbie

                      Thanks Freeman. Below is my beans xml.  I'll work on creating a short example.

                      Barry

                       

                       

                      • 8. Re: DVFactoryException during Spring bean creation
                        Barry Hathaway Newbie

                        I finally created a short example. It is attached along with the servicemix log file.

                        The example is in OSGI-OPT\src\main\java\com\epimorphics\support\JenaTest.java

                        along with a Maven pom.xml to build the bundle.  It users two other bundles from

                        the Jena open source project.  Pom.xml files to build these bundles are also attached.

                        It log seems to indicate that the program has problems with creating the class

                         

                            static protected class SAXParserWithEncodingCheck extends SAXParser {

                                protected SAXParserWithEncodingCheck(StandardParserConfiguration c) {

                                    super(c);

                                }

                         

                        probably because SAXParserWithEncodingCheck  and SAXParser are in different bundles.

                        Thanks.

                         

                        Barry

                        • 9. Re: DVFactoryException during Spring bean creation
                          Freeman(Yue) Fang Master

                          Hi,

                           

                          Somehow I can't build OSGI-OPT project, get errors like

                          Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project jena-test: Compilation failure: Compilation failure:

                          /Users/ffang/issues/thread_3327/fuse-bug/OSGI-OPT/src/main/java/com/epimorphics/support/JenaTest.java:[36,51] package com.ge.research.sadl.sadlserver.cxf.provider does not exist

                          /Users/ffang/issues/thread_3327/fuse-bug/OSGI-OPT/src/main/java/com/epimorphics/support/JenaTest.java:[37,51] package com.ge.research.sadl.sadlserver.cxf.provider does not exist

                          Do I miss something?

                           

                          Freeman

                          • 10. Re: DVFactoryException during Spring bean creation
                            Barry Hathaway Newbie

                            Sorry Freeman, I commented out the statements that use those imports, but neglected to comment out those two imports:

                             

                            // import com.ge.research.sadl.sadlserver.cxf.provider.ISadlServiceProvider;

                            // import com.ge.research.sadl.sadlserver.cxf.provider.SadlServiceProvider;

                             

                            P.S. I'm in the process of getting in touch with one of GE's "named" contact so this issue can go through the normal support process.

                            • 11. Re: DVFactoryException during Spring bean creation
                              Freeman(Yue) Fang Master

                              Hi,

                               

                              I played with this testcase and I can't see any exception you mentioned here, I deployed three bundles and from the FUSE ESB console I saw some printout like

                              Test bundle ...

                              No data

                              I'm using FUSE ESB 4.4.1-fuse-01-06 btw.

                               

                              Few more questions,

                              1.Did you change any configuration of FUSE ESB, something like adjust the featuresBoot in etc/org.apache.karaf.features.cfg?

                              2. Did you install any other feature before you deploy those three bundle?

                               

                              And yeah, if you have fuse subscription please use that channel to contact us.

                               

                              Freeman

                              • 12. Re: DVFactoryException during Spring bean creation
                                Barry Hathaway Newbie

                                Freeman,

                                 

                                Actually I did neglect to send a data file (it is attached). It needs to go in:

                                src/main/resources/data.rdf

                                Also, please change its path in the java code to data.rdf (get rid of /resources/).

                                By using this file you should get "Success" instead of "No Data".

                                 

                                In any event, even without the file you are not getting any exceptions like I am.

                                My changes from the standard Fuse distribution is really only one - I am using

                                equinox as the karaf framework (instead of felix).

                                 

                                The answers to your two question are:

                                 

                                1.) No changes were made in featuresBoot

                                2.) Yes, I did install a number of bundles:

                                 

                                Apache Felix Web Management Console (3.1.8)

                                Common Eclipse Runtime (3.5.0.v20090520-1800)

                                Eclipse Jobs Mechanism (3.4.100.v20090429-1800

                                )

                                Eclipse Preferences Mechanism (3.3.0.v20100503

                                )

                                Extension Registry Support (3.4.100.v20090520-

                                1800)

                                Equinox Application Container (1.3.0.v20100512

                                )

                                Eclipse Content Mechanism (3.4.100.v20100505-1

                                235)

                                Core Runtime (3.6.0.v20100505)

                                Expression Language (3.4.200.v20100505)

                                Core File Systems (1.3.0.v20100526-0737)

                                Core Resource Management (3.6.0.v20100526-0737

                                )

                                EMF Common (2.4.0.v200902171115)

                                EMF Ecore (2.3.0.v200706262000)

                                Apache Commons IO Bundle (1.4)

                                wrap_mvn_junit_junit_4.8.2 (0)