Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JDBC Auth Realm Problems (Tomcat/MySQL)

11 views
Skip to first unread message

Jim

unread,
Sep 23, 2002, 8:04:58 AM9/23/02
to
I'm trying to define a JDBC authorization realm in Tomcat (4.0.3 on
Mac OS X) that connects to user and role tables defined in MySQL
(11.16) using the MySQL JDBC driver (2.0.14). No matter what I try, I
end up with "Catalina.start: LifecycleException: Exception opening
database connection: java.sql.SQLException: org.gjt.mm.mysql.Driver".
I need more information on what the SQL exception is in order to
resolve the problem. Any ideas? Is it a classpath problem? A syntax
error or typo? A misconfiguration?

I'm starting Tomcat with:

#!/bin/sh
export CATALINA_HOME=/usr/local/tomcat
export JAVA_HOME=/usr
$CATALINA_HOME/bin/startup.sh

I have the JDBC driver files in the following spots:

/usr/local/tomcat/
classes/
org/gjt/mm/mysql/
Driver.class
Driver.java
lib/
mysql-connector-java-2.0.14-bin.jar

Here's my realm configuration in Tomcat's server.xml:

<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="org.gjt.mm.mysql.Driver"
connectionURL="jdbc:mysql://localhost/test?user=user;password=password"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />

Here's the exception error:

Starting service Tomcat-Standalone
Apache Tomcat/4.0.3
Catalina.start: LifecycleException: Exception opening database
connection: java.sql.SQLException: org.gjt.mm.mysql.Driver
LifecycleException: Exception opening database connection:
java.sql.SQLException: org.gjt.mm.mysql.Driver
at org.apache.catalina.realm.JDBCRealm.start(JDBCRealm.java:615)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1108)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:343)
at org.apache.catalina.core.StandardService.start(StandardService.java:388)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:506)
at org.apache.catalina.startup.Catalina.start(Catalina.java:781)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:681)
at org.apache.catalina.startup.Catalina.process(Catalina.java:179)
at java.lang.reflect.Method.invoke(Native Method)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:243)
----- Root Cause -----
java.sql.SQLException: org.gjt.mm.mysql.Driver
at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:538)
at org.apache.catalina.realm.JDBCRealm.start(JDBCRealm.java:613)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1108)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:343)
at org.apache.catalina.core.StandardService.start(StandardService.java:388)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:506)
at org.apache.catalina.startup.Catalina.start(Catalina.java:781)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:681)
at org.apache.catalina.startup.Catalina.process(Catalina.java:179)
at java.lang.reflect.Method.invoke(Native Method)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:243)

=?ISO-8859-15?Q?J=F8rgen N=F8rgaard

unread,
Sep 24, 2002, 9:27:44 AM9/24/02
to
You can connect to the database with the given credentials from command
line?

Jim

unread,
Sep 25, 2002, 4:06:13 AM9/25/02
to
Yeah, connecting to the DB from the command line works fine.

I finally figured out the problem -- it was a classpath issue. I
figured it might have been that, but I was thrown by the fact that it
did not say "Class not found".

My solution was to use the following script to start Tomcat. I
probably went overboard with the classpath stuff (I'm new at this),
but it works! If you think any of this is redundant or bad, let me
know. Thanks!

Jim

#!/bin/sh

# Java Classpath
export JAVA_HOME=/usr
#export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
export JAVA_CLASSES=/System/Library/Frameworks/JavaVM.framework/Classes
export JAVA_CLASSPATH=$JAVA_CLASSES/classes.jar:$JAVA_CLASSES/i18n.jar:$JAVA_CLASSES/sunrsasign.jar:$JAVA_CLASSES/ui.jar:

# Tomcat Classpath
export CATALINA_HOME=/usr/local/tomcat
export TOMCAT_HOME=$CATALINA_HOME
export TOMCAT_LIB=$TOMCAT_HOME/common/lib
export TOMCAT_ADDONS=$TOMCAT_LIB/mysql-connector-java-2.0.14-bin.jar:
export TOMCAT_CLASSES=$TOMCAT_HOME/classes:$TOMCAT_HOME/common/classes:
export TOMCAT_LIBS=$TOMCAT_LIB/servlet.jar:$TOMCAT_LIB/activation.jar:$TOMCAT_LIB/jndi.jar:$TOMCAT_LIB/mail.jar:$TOMCAT_LIB/xerces
.jar:$TOMCAT_LIB/jdbc2_0-stdext.jar:$TOMCAT_LIB/jta_spec1_0_1.jar:$TOMCAT_LIB/naming-common.jar:$TOMCAT_LIB/naming-resources.jar:$
TOMCAT_LIB/tyrex-0.9.7.0.jar:
export TOMCAT_CLASSPATH=$TOMCAT_ADDONS$TOMCAT_CLASSES$TOMCAT_LIBS

# Classpath
export CLASSPATH=$JAVA_CLASSPATH$TOMCAT_CLASSPATH.

$CATALINA_HOME/bin/startup.sh

=?ISO-8859-15?Q?J=F8rgen N=F8rgaard <jnpN...@smartNospaMtv.dk>?= wrote in message news:<20020924152...@news.tele.dk>...

sykesdev

unread,
Jan 8, 2003, 2:22:32 PM1/8/03
to

I noticed this problem,

Check that your mm.mysql driver is in <tomcat_home>/common/lib

:-)

--
Posted via http://dbforums.com

0 new messages