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 Rashmi Dave <ra...@persistent.co.in> on 2006/01/30 17:44:04 UTC
iBatis and Tomcat
Hi All,
My question might not relate completely with an iBATIS problem, however, I
am a little desperate and would really appreciate some help.
I have an application which I am deploying as a WAR onto a tomcat 5.5
server. The application contains a daoConfig and an SQLMapConfig. The WAR
file looks like
App.war =
- config (dataaccess.config and other config files)
- screens (containing jsp pages)
- WEB-INF (contains struts-config, web.xml)
o Lib (related lib files)
o Classes
When I deploy the app on the tomcat server, daoConfig is initialized in the
ActionServlet class. For initializing this config, I have had to supply the
exact path name to the config file rather than a relative one. This is
because I find that File f = new File("."); sysout f. getCanonicalPath()
prints the TOMCAT_HOME and not the App directory in TOMCAT_HOME as I would
have expected.
I also find that supplying a relative path in daoConfig.xml for SQLMapConfig
isn't working. I tried giving the actual path (instead of the package
hierarchy) however even that's not working. I get the following exception
Caused by: com.ibatis.dao.client.DaoException: Error configuring SQL Map.
Cause
: java.io.IOException: Could not find resource E:\ source\Ap
p\WEB-INF\src\com\eobone\uam\dblayer\impl\sqlmap\config\SQLMapConfig.xml
at
com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManage
r(XmlDaoManagerBuilder.java:127)
What am I doing wrong? Do I need to configure something in tomcat? Please
help.
Thanks!!!
Rashmi
RE: iBatis and Tomcat
Posted by Rashmi Dave <ra...@persistent.co.in>.
Thanks Nathan, Larry and Tony,
I moved the config files to within the classes and then used Resources. Its
working now :-)
Thanks a million!
(PS: I just want to say that I really think this is a great group. The
attitude of the developers is very helpful. Looking at the emails exchanged
here makes me glad that we chose iBatis. I can be sure that my questions
will be answered :) )
Regards
~Rashmi
_____
From: Nathan.Maves@Sun.COM [mailto:Nathan.Maves@Sun.COM]
Sent: Tuesday, January 31, 2006 2:39 AM
To: user-java@ibatis.apache.org
Subject: Re: iBatis and Tomcat
Rashmi,
Not sure how you are using the Resources class but this has always worked
for us in many many webapps.
public class DaoConfig {
private static Log log = LogFactory.getLog(DaoConfig.class);
private static final DaoManager daoManager;
private static final String resource = "scorecard/dao/dao.xml";
private static Reader reader;
static {
try {
reader = Resources.getResourceAsReader(resource);
} catch (IOException e) {
log.error(e, e);
}
daoManager = DaoManagerBuilder.buildDaoManager(reader);
}
/**
* Get the instance of the DaoManager object
* @return DaoManager
*/
public static DaoManager getDaoManager() {
return daoManager;
}
}
On Jan 30, 2006, at 9:44 AM, Rashmi Dave wrote:
Hi All,
My question might not relate completely with an iBATIS problem, however, I
am a little desperate and would really appreciate some help.
I have an application which I am deploying as a WAR onto a tomcat 5.5
server. The application contains a daoConfig and an SQLMapConfig. The WAR
file looks like
App.war =
- screens (containing jsp pages)
-oo
Re: iBatis and Tomcat
Posted by Nathan Maves <Na...@Sun.COM>.
Rashmi,
Not sure how you are using the Resources class but this has always
worked for us in many many webapps.
public class DaoConfig {
private static Log log = LogFactory.getLog(DaoConfig.class);
private static final DaoManager daoManager;
private static final String resource = "scorecard/dao/dao.xml";
private static Reader reader;
static {
try {
reader = Resources.getResourceAsReader(resource);
} catch (IOException e) {
log.error(e, e);
}
daoManager = DaoManagerBuilder.buildDaoManager(reader);
}
/**
* Get the instance of the DaoManager object
* @return DaoManager
*/
public static DaoManager getDaoManager() {
return daoManager;
}
}
On Jan 30, 2006, at 9:44 AM, Rashmi Dave wrote:
> Hi All,
>
>
>
> My question might not relate completely with an iBATIS problem,
> however, I am a little desperate and would really appreciate some
> help.
>
>
>
> I have an application which I am deploying as a WAR onto a tomcat
> 5.5 server. The application contains a daoConfig and an
> SQLMapConfig. The WAR file looks like
>
>
>
> App.war =
>
> - config (dataaccess.config and other config files)
>
> - screens (containing jsp pages)
>
> - WEB-INF (contains struts-config, web.xml)
>
> o Lib (related lib files)
>
> o Classes
>
>
>
>
>
> When I deploy the app on the tomcat server, daoConfig is
> initialized in the ActionServlet class. For initializing this
> config, I have had to supply the exact path name to the config file
> rather than a relative one. This is because I find that File f =
> new File(“.”); sysout f.getCanonicalPath() prints the TOMCAT_HOME
> and not the App directory in TOMCAT_HOME as I would have expected.
>
>
>
> I also find that supplying a relative path in daoConfig.xml for
> SQLMapConfig isn’t working. I tried giving the actual path (instead
> of the package hierarchy) however even that’s not working. I get
> the following exception
>
>
>
> Caused by: com.ibatis.dao.client.DaoException: Error configuring
> SQL Map. Cause
>
> : java.io.IOException: Could not find resource E:\ source\Ap
>
> p\WEB-INF\src\com\eobone\uam\dblayer\impl\sqlmap\config
> \SQLMapConfig.xml
>
> at
> com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManage
>
> r(XmlDaoManagerBuilder.java:127)
>
>
>
> What am I doing wrong? Do I need to configure something in tomcat?
> Please help.
>
>
>
> Thanks!!!
>
> Rashmi
>
>
Re: iBatis and Tomcat
Posted by Larry Meadors <lm...@apache.org>.
Yeah, this is a bit of a mess. :-)
Using new File(".") to get your working directory should never work. :-)
Put the sqlmap files somewhere under classes like Tony suggested, then
use the resource attribute to specify the location of them.
If you want to post your config files, we can help more.
Larry
On 1/30/06, Rashmi Dave <ra...@persistent.co.in> wrote:
>
>
> I have an application which I am deploying as a WAR onto a tomcat 5.5
> server. The application contains a daoConfig and an SQLMapConfig. The WAR
> file looks like
>
>
>
> App.war =
>
> - config (dataaccess.config and other config files)
>
> - screens (containing jsp pages)
>
> - WEB-INF (contains struts-config, web.xml)
>
> o Lib (related lib files)
>
> o Classes
>
>
>
>
>
> When I deploy the app on the tomcat server, daoConfig is initialized in the
> ActionServlet class. For initializing this config, I have had to supply the
> exact path name to the config file rather than a relative one. This is
> because I find that File f = new File("."); sysout f. getCanonicalPath()
> prints the TOMCAT_HOME and not the App directory in TOMCAT_HOME as I would
> have expected.
>
>
>
> I also find that supplying a relative path in daoConfig.xml for SQLMapConfig
> isn't working. I tried giving the actual path (instead of the package
> hierarchy) however even that's not working. I get the following exception
>
>
>
> Caused by: com.ibatis.dao.client.DaoException: Error
> configuring SQL Map. Cause
>
> : java.io.IOException: Could not find resource E:\ source\Ap
>
> p\WEB-INF\src\com\eobone\uam\dblayer\impl\sqlmap\config\SQLMapConfig.xml
>
> at
> com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManage
>
> r(XmlDaoManagerBuilder.java:127)
>
>
>
> What am I doing wrong? Do I need to configure something in tomcat? Please
> help.
>
>
>
> Thanks!!!
>
> Rashmi