You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Daniel L. Rall" <dl...@finemaltcoding.com> on 2004/11/06 00:13:51 UTC

Re: ClasspathResourceLoader & Struts

Leon, what servlet or J2EE container are you using?  A customer class
loader may be getting in the way of the expected behavior.

On Fri, 2004-08-06 at 08:41 +0200, Leon Messerschmidt wrote:
> Just something to make it even more strage...
> 
> The leading "/" works if the resource is placed in WEB-INF/classes but 
> breaks inside a .jar file in WEB-INF/lib
> 
> ~ Leon
> 
> Geir Magnusson Jr wrote:
> > 
> > On Aug 4, 2004, at 10:46 PM, Leon Messerschmidt wrote:
> > 
> >> Hi All,
> >>
> >> I'm using the ClasspathResourceLoader with Struts & Tiles.  I therefor
> >> need to have a leading "/" in my template names in my tiles-defs file.
> >>
> >> This seem to fail with ClasspathResourceLoader (Sun JDK 1.4.2 / linux).
> >>  I tested this with:
> >>
> >> this.getClass().getClassLoader.getResource("/path/to/resource")
> >> this.getClass().getClassLoader.getResource("path/to/resource")
> >>
> >> The first one fails, while the second one works.  The only reference 
> >> that I could find in mailing lists archives wat that it would not work 
> >> with the leading "/".
> >>
> >> To fix the problem I added the following to ClasspathResourceLoader:
> >>
> >> if (result == null && name.startsWith("/")) {
> >>   result = classLoader.getResourceAsStream(name.substring(1));
> >> }
> >>
> >> It this something that should go into Velocity Tools, or am I just 
> >> being stupid ;-)
> > 
> > 
> > Into ClasspathResourceLoader
> > 
> > I'm surprised that this changed, or that it's not documented in the JDK 
> > javadocs.
> > 
> > geir
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
-- 
Daniel L. Rall <dl...@finemaltcoding.com>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: ClasspathResourceLoader & Struts

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Daniel,

> Leon, what servlet or J2EE container are you using?  A customer class
> loader may be getting in the way of the expected behavior.
I know it doesn't work for Tomcat.  :(
    http://issues.apache.org/bugzilla/show_bug.cgi?id=31703

> > The leading "/" works if the resource is placed in WEB-INF/classes but
> > breaks inside a .jar file in WEB-INF/lib

Best regards,
-- Shinobu Kawai

-- 
Shinobu Kawai <sh...@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org