You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Clinton Begin <cl...@gmail.com> on 2006/01/20 17:55:56 UTC

Re: Resources

Because JAR files mess up the resource path.  You'd probably have to use
something goofy like "jar!/sqlMapConfig.xml"....but I wouldn't depend upon
that.  I suggest just putting them in WEB-INF/classes.

Clinton

On 1/20/06, Tony Qian <da...@aol.com> wrote:
>
> Can someone tell why Resources.getResourceAsReader(sqlMapConfig.xml) can
> not find the sqlMapConfig.xml and sql mapping xml files if I package them
> inside jar file? When I put them under WEB-INF/classes/ (i'm using tomcat),
> everything works okay.
>
> Thanks,
> Tony
>

Re: Resources

Posted by Reuben Firmin <re...@cnet.com>.
If you use this Spring class, you can get resources from jars...


     * @param resource e.g. "classpath:your/package/here/Blah.xml"

    public static Resource getClasspathResource(String resource) {
        PathMatchingResourcePatternResolver res = new 
PathMatchingResourcePatternResolver();
        return res.getResource(resource);
    }

Clinton Begin wrote:

> Because JAR files mess up the resource path.  You'd probably have to 
> use something goofy like "jar!/sqlMapConfig.xml"....but I wouldn't 
> depend upon that.  I suggest just putting them in WEB-INF/classes.
>
> Clinton
>
> On 1/20/06, *Tony Qian* <daqiqian2@aol.com <ma...@aol.com>> 
> wrote:
>
>     Can someone tell why
>     Resources.getResourceAsReader(sqlMapConfig.xml) can not find the
>     sqlMapConfig.xml and sql mapping xml files if I package them
>     inside jar file? When I put them under WEB-INF/classes/ (i'm using
>     tomcat), everything works okay.
>
>     Thanks,
>     Tony
>
>

Re: Resources

Posted by Larry Meadors <lm...@apache.org>.
I have also seen cases where you have to use a leading / with
different classloaders, I know, it sounds retarded (and IMO, it is),
but it has worked for me in the past.

Larry

On 1/20/06, Clinton Begin <cl...@gmail.com> wrote:
> Because JAR files mess up the resource path.  You'd probably have to use
> something goofy like "jar!/sqlMapConfig.xml"....but I wouldn't depend upon
> that.  I suggest just putting them in WEB-INF/classes.
>
>  Clinton
>
>
> On 1/20/06, Tony Qian <da...@aol.com> wrote:
> > Can someone tell why Resources.getResourceAsReader(sqlMapConfig.xml) can
> not find the sqlMapConfig.xml and sql mapping xml files if I package them
> inside jar file? When I put them under WEB-INF/classes/ (i'm using tomcat),
> everything works okay.
> >
> > Thanks,
> > Tony
> >
>
>