Results 1 to 3 of 3

Thread: Spring ResourceServlet in OSGi environment

  1. #1
    Join Date
    Mar 2010
    Posts
    2

    Post Spring ResourceServlet in OSGi environment

    // Moved from web section by author
    Hello everybody. I develop small application in university based on OSGi containers. (Right now I'm using Equinox, but it doesn't matter).

    Application include 4 parts (may be there will be more in the future):
    • domain - model classes
    • dao - data access tier based on hibernate
    • service (not exist yet) - business logic tier, including services for using dao from web
    • web - front-end tier based on Spring WebFlow + MVC


    Now I'm developing a web tier and have a strange problem with Spring ResourceServlet. When I deploy my application in OSGi environment (using maven and pax) there are working fine, but ResourceServlet can't find resources in META-INF directory. Actually I gave following messages:

    Code:
    [btpool0-7] DEBUG org.springframework.web.servlet.DispatcherServlet - Successfully completed request
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Checking last modified of resource: /dijit/themes/tundra/tundra.css
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/dijit/themes/tundra/tundra.css
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Attempting to GET resource: /dijit/themes/tundra/tundra.css
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/dijit/themes/tundra/tundra.css
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Resource not found: /dijit/themes/tundra/tundra.css
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Checking last modified of resource: /css-framework/css/tools.css
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/css-framework/css/tools.css
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Attempting to GET resource: /css-framework/css/tools.css
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/css-framework/css/tools.css
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Resource not found: /css-framework/css/tools.css
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Checking last modified of resource: /spring/Spring.js
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/spring/Spring.js
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Attempting to GET resource: /spring/Spring.js
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/spring/Spring.js
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Resource not found: /spring/Spring.js
    [btpool0-0] DEBUG org.springframework.js.resource.ResourceServlet - Checking last modified of resource: /css-framework/css/forms.css
    [btpool0-4] DEBUG org.springframework.js.resource.ResourceServlet - Checking last modified of resource: /css-framework/css/layout.css
    [btpool0-4] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/css-framework/css/layout.css
    [btpool0-4] DEBUG org.springframework.js.resource.ResourceServlet - Attempting to GET resource: /css-framework/css/layout.css
    [btpool0-4] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/css-framework/css/layout.css
    [btpool0-4] DEBUG org.springframework.js.resource.ResourceServlet - Resource not found: /css-framework/css/layout.css
    [btpool0-0] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/css-framework/css/forms.css
    [btpool0-0] DEBUG org.springframework.js.resource.ResourceServlet - Attempting to GET resource: /css-framework/css/forms.css
    [btpool0-0] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/css-framework/css/forms.css
    [btpool0-0] DEBUG org.springframework.js.resource.ResourceServlet - Resource not found: /css-framework/css/forms.css
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Checking last modified of resource: /spring/Spring-Dojo.js
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/spring/Spring-Dojo.js
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Attempting to GET resource: /spring/Spring-Dojo.js
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/spring/Spring-Dojo.js
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Resource not found: /spring/Spring-Dojo.js
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Checking last modified of resource: /css-framework/css/typo.css
    [btpool0-4] DEBUG org.springframework.js.resource.ResourceServlet - Checking last modified of resource: /dojo/dojo.js
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/css-framework/css/typo.css
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Attempting to GET resource: /css-framework/css/typo.css
    [btpool0-4] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/dojo/dojo.js
    [btpool0-4] DEBUG org.springframework.js.resource.ResourceServlet - Attempting to GET resource: /dojo/dojo.js
    [btpool0-0] DEBUG org.springframework.js.resource.ResourceServlet - Checking last modified of resource: /css-framework/css/layout-navtop-localleft.css
    
    [btpool0-4] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/dojo/dojo.js
    [btpool0-0] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/css-framework/css/layout-navtop-localle
    ft.css
    [btpool0-4] DEBUG org.springframework.js.resource.ResourceServlet - Resource not found: /dojo/dojo.js
    [btpool0-0] DEBUG org.springframework.js.resource.ResourceServlet - Attempting to GET resource: /css-framework/css/layout-navtop-localleft.css
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/css-framework/css/typo.css
    [btpool0-7] DEBUG org.springframework.js.resource.ResourceServlet - Resource not found: /css-framework/css/typo.css
    [btpool0-0] DEBUG org.springframework.js.resource.ResourceServlet - Searching classpath for resource: META-INF/css-framework/css/layout-navtop-localle
    ft.css
    [btpool0-0] DEBUG org.springframework.js.resource.ResourceServlet - Resource not found: /css-framework/css/layout-navtop-localleft.css
    I opened org.springframework.js_2.0.5.RELEASE.jar bundle, open META-INF directory and made sure that all searching files exists. I googled but nothing found. I can't understand why ResourceServlet can't see it's own resources and really need in help. Any suggestions or help?

    P.S. Sorry by my terrible English.

  2. #2
    Join Date
    Jan 2010
    Posts
    3

    Default

    I just ran into the same problem and after some time looking into it my conclusion is we can not make the ResourceServlet work in an OSGi environment. The ResourceServlet tries to load resources from jars using the BundleClassLoader of the web bundle. This class loader only sees resources in the web bundle itself. And since existing jars used by the ResourceServlet store their resources in an unexported location somewhere under META-INF (which is the ResourceServlet default location to look), we can also not access them via an Import-Package. I just worked my way around it by copying all the resources I need from the META-INF directories in the various jars into my webapp directory.

    Cheers,
    Pieter

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Sounds like a problem of the internal infrastructure - ResourceServlet does resource lookups using the Servlet API - the underlying implementation should take care of mapping this to the actual war.
    If the war is suppose to import this from another bundle, make sure this actually happens. If you have a special package (like META-INF/) then you could consider shipping the resources as fragments or just copy them from one bundle to the other. Neither issues are ideal unfortunately.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •