2 Replies Latest reply on Mar 15, 2004 5:54 AM by Konstantin

    ServletContext.getResourceAsStream() problem?

    Konstantin Newbie

      Hi all,

      I just discovered that ServletContext.getResourceAsStream()
      can ( and does ) return resource from another webapp
      ( in my case velocity template through WebappResourceLoader )

      I use freshly downloaded 3.2.3 without any changes.


      Is this problem known? Somehow addressed? Any workarounds?

        • 1. Re: ServletContext.getResourceAsStream() problem?
          Konstantin Newbie

          After planting various debug out int my WebappLoader, I just discovered that when I say ServletCcontext.getResource(String),
          it's loaded via JNDI.

          Here is java code fragment:

           for (int i=0; i < paths.length; i++)
           {
           try
           {
           System.err.println("checking path: " + paths);
          
           result = servletContext.getResourceAsStream(paths + name);
          
           /* exit the loop if we found the template */
           if (result != null)
           {
           System.err.println("found resource " + name + " at: " + servletContext.getResource(paths + name));
           break;
           }
           }
           catch (Exception e)
           {
           /* only save the first one for later throwing */
           if (exception == null)
           {
           exception = e;
           }
           }
           }
          


          And here is the result:
          11:41:13,568 ERROR [STDERR] checking path: /
          11:41:13,571 ERROR [STDERR] found resource index.vm at: jndi:/localhost/unadmin/index.vm


          From both webapps identical...


          Is this problem known? Any workarounds? 3.2.0 worked better...

          • 2. Re: ServletContext.getResourceAsStream() problem?
            Konstantin Newbie

            OK, Further investigation shows, that 2 independet web applications can share singleton instance of velocity.

            How is this possible?