ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gordon Ross" <G.R...@ccw.gov.uk>
Subject Re: Using IBATIS From within Tomcat (& Eclipse)
Date Thu, 08 Mar 2007 15:13:25 GMT
>>> On 08 March 2007 at 14:31, in message
<Pine.LNX.4.64.0703081419240.3662@localhost.localdomain>, Graeme J
Sweeney
<ibatis.user@gjsweeney.com> wrote:
> On Thu, 8 Mar 2007, Gordon Ross wrote:
> 
>> Now this wasn't totally surprised as I wasn't sure about the basic
CWD
>> of a tomcat app. In this case (when running under Eclipse) it
appears to
>> be my home directory. So I put the sqlmap.xml file there, and
IBATIS
>> still complains that it can't find the file.
> 
> I can't speak for how Eclipse influences the set up but I would
expect
> your SqlMap.xml to reside in WEB-INF/classes in your document root.
> 
> e.g. /home/user/public_html/WEB-INF/classes

Oh, I know where they live. The problem is getting IBATIS to be able to
read them.

>> So what's going on here ? How can I point IBATIS to the XML config
>> files under Tomcat (& Eclipse)
> 
> You might want to try getResourceAsStream too.

OK. I changed my "Reader reader = Resources..." line to be:

Reader reader = new InputStreamReader(new
FileInputStream("sqlMap.xml"));

It can now read and open the sqlMap.xml file, but it can't open and
read the files pointed to by the "<sqlMap resource="blah.xml" />

I get (ultimately) the error "Could not find resource
/home/gtg/Item.xml";

So back at square one.

Anyway, I think I've solved it. I found (via google) that
getResourcesAsReader actually looks for files relative to the CLASSPATH.
Once I amend my paths to this, it all appears to work (Well, IBATIS
does, the rest of my code doesn't !)

The problem appears to be the errors being returned by the
getResourceAsReader method. The error is wrong. It says it was trying to
open /home/gtg/SiteMap.xml (or whatever) but actually it was trying to
open the file elsewhere.. *sigh*

Thanks,

GTG

Mime
View raw message