You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Somasundaram.S" <so...@india.tejasnetworks.com> on 2005/12/02 15:33:34 UTC

Class Loader Problem

Hi,

I have jakarta-tomcat-5.5.9 installed and have placed packaged classes
which are actually beans in WEB-INF/classes of my web application
archive. I am trying to access mysql through these beans. The code is :
        try {
            Class.forName(Prop.DB_DRIVER);
        } catch (ClassNotFoundException cnfe) {
            cnfe.printStackTrace();
            throw new Exception("Could not find Driver for DB");
        }
        The class Prop is also packaged under WEB-INF/classes and it
loads a properties file in which the driver is specified as
com.mysql.jdbc.Driver. The jar which contains this class
(com.mysql.jdbc.Driver) file is placed in WEB-INF/lib of my web
application archive. Now i get a class not found exception. I am unable
to reproduce this error consistently. Sometimes it is able to load the
class and my jsp works fine after connecting to DB and sometimes it does
not and i get "Could not find Driver for DB" error page in jsp. I do not
have a clue as to why this is happening.  Also i have the same jar in
common/lib and my server.xml, web.xml are modified so that when i login
through j_security_check it is able to connect to db and always lets me
login to web app. It is after i login and try to access the db that it
displays an inconsistent behaviour. Could anyone please help me with
this problem? I am unable to find out where i am going wrong. Any help
will be most appreciated.

Thanks,
Somasundaram.S