Announcement Announcement Module
Collapse
No announcement yet.
Static resources are not loaded from classpath Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Static resources are not loaded from classpath

    Hi
    I'm using spring 3.1.0.RELEASE, spring webflow 2.3.0.RELEASE and I've the following configuration in my app

    Code:
    	
     <mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/web-resources//>
     <mvc:default-servlet-handler/>
    Structure in war is the following:
    Code:
     |-images
     |-META-INF
     |-scripts
           |- modernizr-2.0.4.js
     |-styles
     |-WEB-INF
           |-lib
               |- spring-js-resources-2.3.0.RELEASE.jar
    When I deploy application on local tomcat (mvn tomcat:run), then javascript from jar (e.g. spring/Spring-Dojo.js) is loaded properly. When I deploy it on jboss (5.1.0.GA), then they are not loaded. Other resources (e.g. modernizr-2.0.4.js) are loaded properly in both cases.

    Any ideas what can be wrong or how I can track the problem ?


    Excerpt from logs from tomcat:
    09:53:13,160 DEBUG: ( servlet.resource.ResourceHttpRequestHandler) Trying relative path [spring/Spring-Dojo.js] against base location: ServletContext resource [/] (ResourceHttpRequestHandler.java:161)
    09:53:13,235 TRACE: ( servlet.resource.ResourceHttpRequestHandler) Relative resource doesn't exist or isn't readable: ServletContext resource [/spring/Spring-Dojo.js] (ResourceHttpRequestHandler.java:171)
    09:53:13,241 DEBUG: ( servlet.resource.ResourceHttpRequestHandler) Trying relative path [spring/Spring-Dojo.js] against base location: class path resource [META-INF/web-resources/] ResourceHttpRequestHandler.java:161)
    09:53:13,247 DEBUG: ( servlet.resource.ResourceHttpRequestHandler) Found matching resource: class path resource [META-INF/web-resources/spring/Spring-Dojo.js] (ResourceHttpRequestHandler.java:166)

    Exceprt from logs from jboss:
    2012-01-02 15:27:27,364 DEBUG [org.springframework.web.servlet.resource.ResourceH ttpRequestHandler] (http-10.192.1.100-8080-56) Trying relative path [spring/Spring-Dojo.js] against base location: ServletContext resource [/]
    2012-01-02 15:27:27,365 TRACE [org.springframework.web.servlet.resource.ResourceH ttpRequestHandler] (http-10.192.1.100-8080-56) Relative resource doesn't exist or isn't readable: ServletContext resource [/spring/Spring-Dojo.js]
    2012-01-02 15:27:27,365 DEBUG [org.springframework.web.servlet.resource.ResourceH ttpRequestHandler] (http-10.192.1.100-8080-56) Trying relative path [spring/Spring-Dojo.js] against base location: class path resource [META-INF/web-resources/]
    2012-01-02 15:27:27,365 TRACE [org.springframework.web.servlet.resource.ResourceH ttpRequestHandler] (http-10.192.1.100-8080-56) Relative resource doesn't exist or isn't readable: class path resource [META-INF/web-resources/spring/Spring-Dojo.js]
    2012-01-02 15:27:27,365 DEBUG [org.springframework.web.servlet.resource.ResourceH ttpRequestHandler] (http-10.192.1.100-8080-56) No matching resource found - returning 404

  • #2
    I've got a somewhat similar issue with spring 3.0.6.RELEASE everything works well , however moving to spring 3.1.0.RELEASE causes resources not be loaded:

    http://forum.springsource.org/showth...fter-migration

    You might want as an interim fix to downgrade to 3.0.6.RELEASE just to see if everything works ok or not assuming you have not used the new features within 3.1 .

    regards,
    Javed

    Comment


    • #3
      Thank for a tip, but after I've downgraded to 3.0.6.RELEASE, problem still persists. At the moment I've made a fast workaround with dedicated resource servlet, but it's nasty and will look for a better solution.

      best regards
      Lukas

      Comment


      • #4
        I have the same problem. I'm currently migrating my spring-mvc project from JBOSS 4.2.1.GA to JBOSS 5.1.0.GA.

        I'm using Spring Webflow 2.3.0.RELEASE, Spring 3.0.5 and try to access files from spring-js-resources-2.3.0.RELEASE.jar.

        Everything worked fine on JBOSS 4.2.1.GA but now I can retrieve js and css resources thus the whole app doesn't work anymore. I tried several workarounds and solutions but none worked.

        [DEBUG] 2012-04-25--14-56-49 [DispatcherServlet.doDispatch] Last-Modified value for [/translation-gui/resources/dojo/dojo.js] is: -1;
        [DEBUG] 2012-04-25--14-56-49 [ResourceHttpRequestHandler.getResource] Trying relative path [dojo/dojo.js] against base location: ServletContext resource [/];
        [TRACE] 2012-04-25--14-56-49 [ResourceHttpRequestHandler.getResource] Relative resource doesn't exist or isn't readable: ServletContext resource [/dojo/dojo.js];
        [DEBUG] 2012-04-25--14-56-49 [ResourceHttpRequestHandler.getResource] Trying relative path [dojo/dojo.js] against base location: class path resource [META-INF/web-resources/];
        [TRACE] 2012-04-25--14-56-49 [ResourceHttpRequestHandler.getResource] Relative resource doesn't exist or isn't readable: class path resource [META-INF/web-resources/dojo/dojo.js];
        [DEBUG] 2012-04-25--14-56-49 [ResourceHttpRequestHandler.getResource] Trying relative path [dojo/dojo.js] against base location: class path resource [js/];
        [TRACE] 2012-04-25--14-56-49 [ResourceHttpRequestHandler.getResource] Relative resource doesn't exist or isn't readable: class path resource [js/dojo/dojo.js];

        @karpaczio: How did you solve the problem?

        Comment


        • #5
          Anyone? Come on...

          Comment


          • #6
            Same problem with JBoss 5.1.
            I just put the contents of spring-js-resources-2.2.1.RELEASE.jar under webapp, where the rest of my static resources live.
            Is there anything wrong with that?

            Comment

            Working...
            X