You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Frank Burns <fb...@googlemail.com> on 2007/05/14 20:34:12 UTC
Problems with JDBCRealm and mysql ...
I am successfully running a local web application on Windows XP, using
Tomcat 5.5.20, and a JDBCRealm for the application that accesses two simple
tables (users and user_roles) on a local mysql database.
However, when I try to run the identical set-up on a remote linux server I
get database connectivity problems. A sample logging error message is:
ERROR 14 May 07 12:44:54 - Exception opening database connection
java.sql.SQLException: com.mysql.jdbc.Driver
I can connect to the database and its tables, using the
user/password/database details in the server.xml JDBCRealm specification, as
shown below.
So why can't Tomcat?
Here is an excerpt from the server.xml on the remote linux machine.
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/userroleadmin"
docBase="/opt/tomcat5/webapps/userroleadmin" debug="99">
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/test"
connectionName="frank" connectionPassword="burns"
userTable="users" userNameCol="username"
userCredCol="password"
userRoleTable="user_roles" roleNameCol="role" />
/>
</Context>
Thanks,
Frank Burns.
Re: Problems with JDBCRealm and mysql ...
Posted by Frank Burns <fb...@googlemail.com>.
Hi Chris.
In the in the server.xml JDBCRealm specification, I changed "localhost" to "
127.0.0.1" and it works.
Thanks for your help.
Frank.
On 5/14/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Frank,
>
> Frank Burns wrote:
> > However, when I try to run the identical set-up on a remote linux server
> I
> > get database connectivity problems. A sample logging error message is:
> >
> > ERROR 14 May 07 12:44:54 - Exception opening database connection
> > java.sql.SQLException: com.mysql.jdbc.Driver
>
> Can we get the rest of that exception? The name of the driver isn't
> exactly helpful :(
>
> > I can connect to the database and its tables, using the
> > user/password/database details in the server.xml JDBCRealm
> > specification, as shown below.
>
> How do you connect? Using the mysql command-line interface?
>
> > So why can't Tomcat?
>
> Several things can go wrong.
>
> First, the command-line interface will use a named pipe on the
> filesystem to communicate with the server unless you specify the "-h"
> parameter and use something other than "localhost" (such as 127.0.0.1).
> If your MySQL server is configured to disable TCP/IP networking (and
> rely only on this named pipe), then Connector/J will be unable to
> connect (Connector/J uses sockets to connect, and requires TCP/IP
> networking to be enabled on the server). See /etc/my.conf and friends to
> see if the "skip-networking" setting it active. If it is, then you'll
> have to disable it and restart MySQL in order to use Connector/J. Not
> sure why this wouldn't be the case on win32... win32 has named pipes (of
> a sort), but I'm not entirely sure how they are supported by MySQL.
>
> The second thing that can go wrong is the name of localhost. This used
> to be a problem back in the day with Linux distros that has host files
> that declared localhost.localdomain to be the first alias to 127.0.0.1
> instead of plain-old "localhost". This makes connections to 127.0.0.1
> from Java look like they are coming from "localhost.localdomain" to
> MySQL. Since MySQL does pretty simple host checking, and you are likely
> to have created users like 'myapp@localhost', the authentication fails.
> Check /etc/hosts to ensure that "localhost" is the first alias for
> 127.0.0.1. Alternatively, you can add a GRANT in MySQL for
> 'myapp@localhost.localdomain'.
>
> There could be other things wrong, but these are the most obvious to me
> to try first.
>
> - -chris
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFGSNDW9CaO5/Lv0PARAsQYAJ4iCcglCT6f0jssMcHR1mu9J1DjWQCgvYDF
> vc4QrWyTeyzE7dljgdDEfBk=
> =LwyE
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Re: Problems with JDBCRealm and mysql ...
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Frank,
Frank Burns wrote:
> However, when I try to run the identical set-up on a remote linux server I
> get database connectivity problems. A sample logging error message is:
>
> ERROR 14 May 07 12:44:54 - Exception opening database connection
> java.sql.SQLException: com.mysql.jdbc.Driver
Can we get the rest of that exception? The name of the driver isn't
exactly helpful :(
> I can connect to the database and its tables, using the
> user/password/database details in the server.xml JDBCRealm
> specification, as shown below.
How do you connect? Using the mysql command-line interface?
> So why can't Tomcat?
Several things can go wrong.
First, the command-line interface will use a named pipe on the
filesystem to communicate with the server unless you specify the "-h"
parameter and use something other than "localhost" (such as 127.0.0.1).
If your MySQL server is configured to disable TCP/IP networking (and
rely only on this named pipe), then Connector/J will be unable to
connect (Connector/J uses sockets to connect, and requires TCP/IP
networking to be enabled on the server). See /etc/my.conf and friends to
see if the "skip-networking" setting it active. If it is, then you'll
have to disable it and restart MySQL in order to use Connector/J. Not
sure why this wouldn't be the case on win32... win32 has named pipes (of
a sort), but I'm not entirely sure how they are supported by MySQL.
The second thing that can go wrong is the name of localhost. This used
to be a problem back in the day with Linux distros that has host files
that declared localhost.localdomain to be the first alias to 127.0.0.1
instead of plain-old "localhost". This makes connections to 127.0.0.1
from Java look like they are coming from "localhost.localdomain" to
MySQL. Since MySQL does pretty simple host checking, and you are likely
to have created users like 'myapp@localhost', the authentication fails.
Check /etc/hosts to ensure that "localhost" is the first alias for
127.0.0.1. Alternatively, you can add a GRANT in MySQL for
'myapp@localhost.localdomain'.
There could be other things wrong, but these are the most obvious to me
to try first.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGSNDW9CaO5/Lv0PARAsQYAJ4iCcglCT6f0jssMcHR1mu9J1DjWQCgvYDF
vc4QrWyTeyzE7dljgdDEfBk=
=LwyE
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Problems with JDBCRealm and mysql ...
Posted by "Raghupathy, Gurumoorthy" <Gu...@nielsen.com>.
Are you sure that the database is at localhost:3306/test
Just make sure that the remote linux server has a MYSQL server running
....
-----Original Message-----
From: Frank Burns [mailto:fbittech@googlemail.com]
Sent: 14 May 2007 19:34
To: users@tomcat.apache.org
Subject: Problems with JDBCRealm and mysql ...
I am successfully running a local web application on Windows XP, using
Tomcat 5.5.20, and a JDBCRealm for the application that accesses two
simple
tables (users and user_roles) on a local mysql database.
However, when I try to run the identical set-up on a remote linux server
I
get database connectivity problems. A sample logging error message is:
ERROR 14 May 07 12:44:54 - Exception opening database connection
java.sql.SQLException: com.mysql.jdbc.Driver
I can connect to the database and its tables, using the
user/password/database details in the server.xml JDBCRealm
specification, as
shown below.
So why can't Tomcat?
Here is an excerpt from the server.xml on the remote linux machine.
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/userroleadmin"
docBase="/opt/tomcat5/webapps/userroleadmin" debug="99">
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/test"
connectionName="frank" connectionPassword="burns"
userTable="users" userNameCol="username"
userCredCol="password"
userRoleTable="user_roles" roleNameCol="role" />
/>
</Context>
Thanks,
Frank Burns.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org