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 Using IBATIS From within Tomcat (& Eclipse)
Date Thu, 08 Mar 2007 13:54:34 GMT
I'm new to iBatis, and want to use it from within a Tomcat servlet that
I'm developing under Eclipse.

To start with, I knocked up a simple command line app to make sure I
could to what I wanted with IBATIS, and that worked fine. So I
progressed to including IBATIS within my servlet.

My problem is when I try to initalise the sqlmap. I've got the
boiler-plate code of:

	String resource = "SqlMap.xml";
	Reader reader = Resources.getResourceAsReader(resource);
	sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

However, I always get the java exception of:

java.io.IOException: Could not find resource SqlMap.xml

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.

However, if I do a quick:

File file = new java.io.File("SqlMap.xml");
if (file.canRead())
    System.err.println("Can Read");
    System.err.println("Can't Read");

Right before the IBATIS initalisation code, I get a "Can Read" message
on the Tomcat console.

So what's going on here ? How can I point IBATIS to the XML config
files under Tomcat (& Eclipse)

I'm using IBATIS, with Tomcat 5.5.20 and Eclipse 3.2.2



View raw message