Ken Bowen
2007-09-16 14:26:24 UTC
Hello,
I'm working on a CENTOS 5 Linux setup.
I'm trying to avoid the pre-loaded tomcat which was installed in
/usr/share/tomcat5.
I downloaded (from apache) and installed tomcat5.5.25 and installed it
in /opt/tomcat5.
I made sure the existing tomcat is not running and I renamed
/usr/share/tomcat5.
I start it (the new tomcat) with /opt/tomcat5/bin/startup.sh and it runs
fine:
Tomcat manager runs and I can start/stop the built-in apps.
I have an app which I developed using tomcat5.5.9 on Windows, and I am
trying to
transfer it to this Linux setting.
I placed my exploded app in webapps. The app wants to use a Mysql
database named sb_data.
The same database as on Windows has been replicated in Mysql in the
Linux setup.
I have the following context.xml in my META-INF folder:
<Context path="/myapp" docBase="myapp"
debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/sb_data" auth="Container"
type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="sb_normal" password="********"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/sb_data?autoReconnect=true"/>
</Context>
My application has a registered AppListener in which I establish the
DataSource
in the contextInitialized method and use it to do some initial work with
the database:
System.out.println("MyApp AppListener: ENTER");
....
Context envCtx = (Context) initialContext.lookup("java:comp/env");
String key = "jdbc" + "/" + "sb_data";
DataSource ds = (DataSource)envCtx.lookup(key);
if (ds != null ){
DAOBaseData.setDataSource(ds);
}
....
...CALL to DAOBaseData.getConnection(); HERE
....
System.out.println("MyApp AppListener: EXIT");
The code for getConnection() looks like this:
public Connection getConnection() throws DAOException
{
Connection connection = null;
if (datasource!= null) {
try {
connection = datasource.getConnection();
} catch (SQLException e) {
//TODO: Log this
String message = e.getMessage();
System.out.println("DAOBaseData: "+message);
throw new DAOException(message);
}
}
connCount++;
System.out.println("Connection[data] allocated: #="+connCount);
return connection;
}
This works ok on Windows, but in the Linux setting I get the following
error in
the catalina.out log:
MyApp AppListener: ENTER
DAOBaseData: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
com.myapp Error: Cannot load JDBC driver class
'com.mysql.jdbc.Driver'
MyApp AppListener: EXIT
I'm using the mysql-connector-java-3.1.14-bin.jar and it is present in
WEB-INF/lib.
I tried copying it to /opt/tomcat5/common/lib , but I still get the same
error.
I'm confused. Why does tomcat on Windows find the JDBC driver, but not
find it on Linux?
Thanks in advance,
Ken Bowen
---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
I'm working on a CENTOS 5 Linux setup.
I'm trying to avoid the pre-loaded tomcat which was installed in
/usr/share/tomcat5.
I downloaded (from apache) and installed tomcat5.5.25 and installed it
in /opt/tomcat5.
I made sure the existing tomcat is not running and I renamed
/usr/share/tomcat5.
I start it (the new tomcat) with /opt/tomcat5/bin/startup.sh and it runs
fine:
Tomcat manager runs and I can start/stop the built-in apps.
I have an app which I developed using tomcat5.5.9 on Windows, and I am
trying to
transfer it to this Linux setting.
I placed my exploded app in webapps. The app wants to use a Mysql
database named sb_data.
The same database as on Windows has been replicated in Mysql in the
Linux setup.
I have the following context.xml in my META-INF folder:
<Context path="/myapp" docBase="myapp"
debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/sb_data" auth="Container"
type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="sb_normal" password="********"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/sb_data?autoReconnect=true"/>
</Context>
My application has a registered AppListener in which I establish the
DataSource
in the contextInitialized method and use it to do some initial work with
the database:
System.out.println("MyApp AppListener: ENTER");
....
Context envCtx = (Context) initialContext.lookup("java:comp/env");
String key = "jdbc" + "/" + "sb_data";
DataSource ds = (DataSource)envCtx.lookup(key);
if (ds != null ){
DAOBaseData.setDataSource(ds);
}
....
...CALL to DAOBaseData.getConnection(); HERE
....
System.out.println("MyApp AppListener: EXIT");
The code for getConnection() looks like this:
public Connection getConnection() throws DAOException
{
Connection connection = null;
if (datasource!= null) {
try {
connection = datasource.getConnection();
} catch (SQLException e) {
//TODO: Log this
String message = e.getMessage();
System.out.println("DAOBaseData: "+message);
throw new DAOException(message);
}
}
connCount++;
System.out.println("Connection[data] allocated: #="+connCount);
return connection;
}
This works ok on Windows, but in the Linux setting I get the following
error in
the catalina.out log:
MyApp AppListener: ENTER
DAOBaseData: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
com.myapp Error: Cannot load JDBC driver class
'com.mysql.jdbc.Driver'
MyApp AppListener: EXIT
I'm using the mysql-connector-java-3.1.14-bin.jar and it is present in
WEB-INF/lib.
I tried copying it to /opt/tomcat5/common/lib , but I still get the same
error.
I'm confused. Why does tomcat on Windows find the JDBC driver, but not
find it on Linux?
Thanks in advance,
Ken Bowen
---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org