You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Brian Richards <nc...@pobox.com> on 2001/10/04 06:53:39 UTC

Driver fails to load on two webapps

Ok I am running two applications that use the IBM DB2 appdriver to connect
to two different databases.  The problem is this when i start up tomcat only
one of the applications can access the database.  The first one to have a
request made wins and the other app gets a No Suitable Driver exception.
They both work independtly as long as it's the first one requested.  My
theory is that the Class.forName(driver) being called twice is mucking
things up the code at fault is:

The obeject that owns this code is instatiated in in jspInit() and load is
called only once.

Any other theories?

Thanks

Brian

ps
I'm using Tomcat 3.3, jdk1.3.1 WIN2k. and Apace 1.3.6
and the two applications are in two different virtual hosts

<Context path="/" docBase="E:/csc/513/htdocs" debug="0" reloadable="true"
trusted="false"/>

<Host name="dafs.dyndns.org" >
            <Context path="/messages" docBase="webapps/jive" debug="0"
reloadable="false" trusted="false"/>
</Host>

but i get teh same error when they are both in the same host.



public Connection driverManager()
 throws SQLException
 {
  return  DriverManager.getConnection(getURL(), getUserID(), getPassword());
 }

 public boolean load(Properties prop)
 {
  if (prop!=null) {
   try {
    driver = (String)prop.get("driver");
    password = (String)prop.get("password");
    URL = (String)prop.get("url");
    userID = (String)prop.get("user");
    dataSourceName = (String)prop.get("datasource");
    try {
     Class.forName(getDriver());
    } catch (ClassNotFoundException cnfe) {
     System.err.println(getDriver()+" could not be found.");
    }
   } catch (NullPointerException npe) {
    return false;
   }
  }
  return true;
 }






Re: Driver fails to load on two webapps

Posted by Brian Richards <nc...@pobox.com>.
Ok I found _A_ solution but I don't really like it.  Basically I had the
db2java.jar file in the lib directory for both webapps.
I moved the jar to only reside in TOMCAT_HOME\lib and updated the
wrapper.properties file.  Now it's magically delicious.  What would be a
better way to resolve this (Something with classloaders?) so that each web
app can have it's own copy of the jar?

Thanks

Brian
----- Original Message -----
From: "Brian Richards" <nc...@pobox.com>
To: <to...@jakarta.apache.org>
Sent: Thursday, October 04, 2001 12:53 AM
Subject: Driver fails to load on two webapps


> Ok I am running two applications that use the IBM DB2 appdriver to connect
> to two different databases.  The problem is this when i start up tomcat
only
> one of the applications can access the database.  The first one to have a
> request made wins and the other app gets a No Suitable Driver exception.
> They both work independtly as long as it's the first one requested.  My
> theory is that the Class.forName(driver) being called twice is mucking
> things up the code at fault is:
>
> The obeject that owns this code is instatiated in in jspInit() and load is
> called only once.
>
> Any other theories?
>
> Thanks
>
> Brian
>
> ps
> I'm using Tomcat 3.3, jdk1.3.1 WIN2k. and Apace 1.3.6
> and the two applications are in two different virtual hosts
>
> <Context path="/" docBase="E:/csc/513/htdocs" debug="0" reloadable="true"
> trusted="false"/>
>
> <Host name="dafs.dyndns.org" >
>             <Context path="/messages" docBase="webapps/jive" debug="0"
> reloadable="false" trusted="false"/>
> </Host>
>
> but i get teh same error when they are both in the same host.
>
>
>
> public Connection driverManager()
>  throws SQLException
>  {
>   return  DriverManager.getConnection(getURL(), getUserID(),
getPassword());
>  }
>
>  public boolean load(Properties prop)
>  {
>   if (prop!=null) {
>    try {
>     driver = (String)prop.get("driver");
>     password = (String)prop.get("password");
>     URL = (String)prop.get("url");
>     userID = (String)prop.get("user");
>     dataSourceName = (String)prop.get("datasource");
>     try {
>      Class.forName(getDriver());
>     } catch (ClassNotFoundException cnfe) {
>      System.err.println(getDriver()+" could not be found.");
>     }
>    } catch (NullPointerException npe) {
>     return false;
>    }
>   }
>   return true;
>  }
>
>
>
>
>
>
>