Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-1457

ServletContext getResourcePaths are not returning relative paths

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 8.0.0.Alpha2
    • 8.0.0.Alpha1
    • Web (Undertow)
    • None
    • Hide

      1. deploy the attached reproducer (modified helloworld quickstart)
      2. go to http://127.0.0.1:8080/jboss-as-helloworld/HelloWorld
      3. notice the output

      Show
      1. deploy the attached reproducer (modified helloworld quickstart) 2. go to http://127.0.0.1:8080/jboss-as-helloworld/HelloWorld 3. notice the output

      ServletContext getResourcePaths should return "relative paths", according to

      http://docs.oracle.com/javaee/6/api/javax/servlet/ServletContext.html#getResourcePaths%28java.lang.String%29

      the result of which the returned paths won't work if passed to ServletContext getResource method, which expects relative paths and will return null URLs

      Having a simple servlet

      Set<String> paths = req.getServletContext().getResourcePaths("/WEB-INF/classes");
          	
              resp.setContentType("text/plain");
              PrintWriter writer = resp.getWriter();
              
              for (String path : paths) {
              	writer.println(path + " , url: " + req.getServletContext().getResource(path));
              }
              
              writer.close();
      

      will result in

      /home/maschmid/testing/wildfly-8.0.0.Alpha2-SNAPSHOT/standalone/tmp/vfs/temp9578b420b6a0dfd8/content-b6b9429f41b85866/WEB-INF/classes/hello.resource , url: null
      /home/maschmid/testing/wildfly-8.0.0.Alpha2-SNAPSHOT/standalone/tmp/vfs/temp9578b420b6a0dfd8/content-b6b9429f41b85866/WEB-INF/classes/my.properties , url: null
      /home/maschmid/testing/wildfly-8.0.0.Alpha2-SNAPSHOT/standalone/tmp/vfs/temp9578b420b6a0dfd8/content-b6b9429f41b85866/WEB-INF/classes/org , url: null
      

      while the expected output would be, e.g. the following result of EAP 6.1:

      /WEB-INF/classes/hello.resource , url: jndi:/default-host/jboss-as-helloworld/WEB-INF/classes/hello.resource
      /WEB-INF/classes/org/ , url: jndi:/default-host/jboss-as-helloworld/WEB-INF/classes/org/
      /WEB-INF/classes/my.properties , url: jndi:/default-host/jboss-as-helloworld/WEB-INF/classes/my.properties
      

            sdouglas1@redhat.com Stuart Douglas
            maschmid@redhat.com Marek Schmidt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: