5 Replies Latest reply on Feb 28, 2011 6:07 AM by bosschaert

    Spring xsd classpath issue in OSGI

    yarafatin

      Hello Folks,

       

      I am using the jboss-osgi-installer-1.0.0.Beta6.jar and made JBOSS 5.1 OSGI enabled (Felix).

       

      I am deploying a few bundles which has spring bean xmls.

      After the server starts, I get an exception that the schema document for "http://www.springframework.org/schema/beans/spring-beans.xsd" is not found, which I believe is due to a classpath issue. Spring looks for the xsd file given in the schema.handlers file located in the spring-bean.jar (2.5.6)

       

      Can someone tell me how to set this jar in the base framework and have the bundles leverage it.

       

       

      BTW, the exception trace,

      {quote}

      org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

          at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)

          at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:96)

          at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:380)

          at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)

          at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:2541)

          at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaWarning(XSDHandler.java:2532)

          at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:1836)

          at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:531)

          at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:552)

          at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(XMLSchemaValidator.java:2436)

          at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1781)

          at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705)

          at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400)

          at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:626)

          at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3103)

          at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:922)

          at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)

          at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)

          at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)

          at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)

          at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)

          at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)

          at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:235)

          at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)

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

          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.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:176)

          at org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:142)

          at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)

          at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)

          at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$800(AbstractDelegatedExecutionApplicationContext.java:69)

          at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$3.run(AbstractDelegatedExecutionApplicationContext.java:269)

          at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)

          at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.startRefresh(AbstractDelegatedExecutionApplicationContext.java:247)

          at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:222)

          at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:175)

          at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:175)

          at org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:718)

          at java.lang.Thread.run(Thread.java:619)

      {quote}

        • 1. Spring xsd classpath issue in OSGI
          bosschaert

          Are you connected to the internet?

          I think there is an issue with Spring 2.5.6 in that it connects to the internet to read its xsd's even if it is part of the jar.

           

          Apparently it's fixed in Spring 3.x

           

          A similar issue is reported in a different context here: https://issues.apache.org/jira/browse/DOSGI-69

          • 2. Spring xsd classpath issue in OSGI
            yarafatin

            Thanks for the reply David.

             

             

            I am connected to the internet and could get to the URL, showing the schema - http://www.springframework.org/schema/beans/spring-beans.xsd

            I also tried upgrading to 3.0.5 version of spring, but in vain.

             

            I am going to move the spring jars to JBOSS lib directory and have them loaded as system libs instead of OSGI bundles and see if that can resolve this.

             

            Any other thoughts?

            • 3. Spring xsd classpath issue in OSGI
              yarafatin

              I tried adding a simple spring osgi bundle and it worked fine.

               

              The problem seems to be when adding the servicemix bundles. I just place them under the deploy/osgi directory.

               

              Is there a way I can place the spring xsds at the top level of the classpath where all bundles can see it?

              • 4. Spring xsd classpath issue in OSGI
                yarafatin

                I resolved the classpath issue by removing unwanted bundle jars of servicemix.

                 

                Removed all servicemix jars from jboss osgi directory. Added spring jars (with osgi) first. They were dependent on the following jars -

                org.apache.servicemix.bundles.aopalliance-1.0_3.jar, geronimo-jms_1.1_spec-1.1.1.jar.

                 

                Adde servicemix-common and service-util jars, since they form the core depenecy. It needed the following jars - mail-1.4.3.jar, org.apache.servicemix.specs.jbi-api-1.0-1.4.0.jar, org.apache.servicemix.bundles.wsdl4j-1.6.2_2.jar,xbean-classloader-3.5.jar, xbean-spring-3.5.jar

                 

                Added servicemix-bean-2010.01.jar  and service-file-2010.01.jar. No errors on startup.

                 

                 

                The sad news is that none of the examples work as a servicemix component.

                 

                I will keep digging into this. If anyone has done this before or have any pointers, please let me know. Thanks.

                • 5. Spring xsd classpath issue in OSGI
                  bosschaert

                  Hi Yasser,

                   

                  That sounds like good progress! Do let us know if you find out why those examples don't work. I assume you are referring to ServiceMix examples...

                   

                  Best regards,

                   

                  David