ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Meadors <larry.mead...@gmail.com>
Subject Re: Config files loading
Date Tue, 04 Oct 2005 12:10:24 GMT
You have a few options:

Option #1 - talk to the customer, explain the problem, and see if they
are willing to bend. IMO, this is an incredibly STUPID requirement.
Putting a configuration file in the root of your web app is like
leaving the keys to your house in the door. VERY bad idea. Putting
database.properties there is like taping your credit cards to them.
VERY, VERY bad idea. The reason we have the WEB-INF directory is to
hide stuff like this. To have a requirement *not* to use it is

Option #2: Use a ServletContextListener to construct your dao and poke
it into application scope (another bad pattern - mixing dao with web

    public void contextInitialized(ServletContextEvent servletContextEvent) {
        try {
            String path =
            Reader urlAsReader = Resources.getUrlAsReader("file://" + path);
            DaoManager daoManager =
        } catch (IOException e) {
            throw new RuntimeException(e);

Push for #1, my friend. :)


On 10/4/05, Gajendra Naidu <gajendra.naidu@gmail.com> wrote:
> I am using iBatis for the web application which I am developing.  Here I
> have a problem in loading config files such as dao.xml, sql-map-config.xml &
> database.properties all these files are located in web root folder(This is a
> requirement from customer).
> I am able to load this files if they reside in 'WEB-INF/classes'
> directory(reader = Resources.getResourceAsReader("dao.xml")).
> I have a problem loading config files if they are in web root directory.
> Can some body direct me in solving the above issue.
> Thanks in advance
> Gaj

View raw message