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



Reply via email to