3 Replies Latest reply on Jan 4, 2011 11:34 AM by jtellier

    Spring xsd cannot be found

    jtellier

      Hello,

       

      I am currently working at repackaging a non-OSGi webapp into an OSGi bundle and I'm having some problems.

       

      Basically, my problem lies within that exception:

       

      java.io.FileNotFoundException: class path resource cannot be opened because it does not exist

       

      The thing is, however, that this file is present in two places, under the correct path:

      - In my bundle jar file

      - In spring-beans-3.0.3.RELEASE.jar, a bundle that is activated in the OSGi container

       

      Even though all the necessary spring components are activated in the OSGi container, I've bundled them (and declared them as Private-Packages) with my application as well because it's using an older version (but maybe I could try to see if the version activated within the OSGi container would work...)

       

      So this problem causes another one: a SAXParseException when loading spring config files because the "bean" element cannot be found. This makes sense since the xsd declaring this element is not found...

       

      Does anyone have an idea why the spring-beans-2.0.xsd file cannot be found, even though it seems to be present in the classpath?

       

      Thanks,

      Jonathan

       

      Edited by: jtellier on Dec 23, 2010 5:58 PM

        • 1. Re: Spring xsd cannot be found
          njiang

          I don't know how did you start the application?

          Did you use the Spring DM to load the application context ?

          If so, that could explain that Spring DM can find the xsd file as the file is in your bundle's private package.

           

          Willem

          • 2. Re: Spring xsd cannot be found
            ffang

            Hi,

             

            You should always avoid embedding framework shared bundles like spring/xml parser into your bundle, it could cause problems. there's a similar discussion you may want to take a look[1]

             

            http://fusesource.com/forums/thread.jspa?messageID=8674&#8674

             

            Freeman

            • 3. Re: Spring xsd cannot be found
              jtellier
              njiang wrote:

              I don't know how did you start the application?

              Did you use the Spring DM to load the application context ?

               

              I'm not sure I correctly understand you question. My application is a webapp that was previously packaged as a WAR deployed inside Tomcat. I took the content of that WAR and put it in a bundle (actually, it's packaged as a feature) along with its dependencies. This bundle has an Activator that creates an org.mortbay.jetty.Server and WebAppContext, initializes them to mimic the web.xml that was in the WAR and starts them. The Activator does not interact with spring object, except for that specific part (ContextLoaderListener is a spring class):

               

              WebAppContext root = new WebAppContext(server, bundleUrlString, contextPath)

              \[...\]

              root.addEventListener(new ContextLoaderListener());

               

              Then, at the karaf prompt, I call features:install on my feature to, well... install my feature...

               

              Does that help?

               

              ffang wrote:

              You should always avoid embedding framework shared bundles like spring/xml parser into your bundle, it could cause problems. there's a similar discussion you may want to take a look[1]

               

              I've just tried to get rid of all things spring related in my bundle and use the already activated spring bundles that are in my OSGi container instead. However, this gives me the following error:

               

              Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace http://www.springframework.org/schema/util

               

              Now, I did previously encounter this problem and this solution solved it. However, since the solution involves having a spring.handlers and a spring.schemas that refers to spring classes and XSDs that are not present in my bundle anymore, I decided to undo it. Nevertheless, the error still persists.

               

              My theory is that when the solution is in place, spring.handlers and spring.schemas refer to non-existing objects, so I get the error. On the other hand, when the solution is not in place, spring looks for objects that are not declared in spring.handlers and spring.schemas. So whatever I do, I get the same error. Would that make sense?

               

              Thanks,

              --jtellier

               

              http://www.hagelnx.com/prog/814

               

              Edited by: jtellier on Jan 4, 2011 4:34 PM