You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jan Strauch <wa...@web.de> on 2007/04/25 01:26:02 UTC

Tomcat UserDB in MySQL

I want to replace the "tomcat-users.xml" with two tables in MySQL:

Database : auth
table users :    username varchar(15) primary key NN
                    pass varchar(41) NN

table roles :     username varchar(15) primary key NN
                    role varchar(10) NN

Tried the solution from thread "[SOLVED] :) user authetication on MySql db issue need some help!"
from the list, but still doesn´t work.

Are there any more changes I have to make.
Do I need to update TC (now using TC 5.0.28)
I want to avoid an update, because everything else is running fine, and I made 
the experience that updates often change this.

The TC admintool doesn´t  give the possibility to add MySQL userDBs.

Thanks


Re: Tomcat UserDB in MySQL

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jan,

Jan Strauch wrote:
> It still doesn´t work.
> this is what Catalina.out sais:

[snip]

> <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
> <realm className="org.apache.catalina.realm.JDBCRealm"

Note that <Realm> and <realm> are different. Also, if you are using a
JDBCRealm, you should disable the UserDatabaseRealm.

> Why "ajp13 listening on /0.0.0.0:8009" ? Is this normal?

Yes. That means "all interfaces, on port 8009".

> Why are there no entries in catalina.out, localhost_log?  Catalina_log has a size of 0 bytes.

You pasted your catalina.out at the top of this message. What do you
mean "no entries"? Do you mean "why are there no errors related to my
realm?". You have no error messages because you haven't defined a
realm... you defined something that kind of looks like a realm, but
since you used a lowercase "r", Tomcat basically ignores it.

You should be (??) getting an error somewhere about a bad server.xml...
since <realm> isn't recognized as a valid element. I'm not entirely sure
of Tomcat's configuration loader imposes XML validation rules on the
config file, though.

> DB-access has root-permissions.

Whatever that means, I'm sure it's not good. I hope that
conn_name/conn_pass is a normal database user.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGM1qx9CaO5/Lv0PARAn2ZAJ4zBhHVh9GEAWgp/OxkfzvdKfm0QwCePhEw
uYfPx7j6AzTEof+MvxTK2BQ=
=z+aR
-----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: Tomcat UserDB in MySQL

Posted by Jan Strauch <wa...@web.de>.
It still doesn´t work.
this is what Catalina.out sais:

INFO: Starting Coyote HTTP/1.1 on http-8080
27.04.2007 01:14:44 org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
27.04.2007 01:14:44 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/228  config=/jakarta-tomcat-5.0.28/conf/jk2.properties
27.04.2007 01:14:44 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-443
27.04.2007 01:14:44 org.apache.catalina.startup.Catalina start

And the part of server.xml:

<Service name="Catalina">
    <Connector acceptCount="100" connectionTimeout="20000"
    disableUploadTimeout="true" port="8080" redirectPort="443" maxSpareThreads="75" maxThreads="150" minSpareThreads="25">
    </Connector>
    <Connector port="8009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
    redirectPort="443">
    </Connector>
    <Connector className="org.apache.coyote.tomcat5.CoyoteConnector" keystoreFile="/root/.keystore" keystorePass="myKey"
    port="443" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" disableUploadTimeout="true"
    acceptCount="100" debug="0" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" />
    <Engine defaultHost="localhost" name="Catalina">
      <DefaultContext className="org.apache.catalina.core.StandardDefaultContext" reloadable="true">
      </DefaultContext>
      <Host appBase="webapps" name="localhost">
        <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_log." suffix=".txt" timestamp="true"/>
      </Host>
      <Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/>
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase" />
      <realm className="org.apache.catalina.realm.JDBCRealm" debug="99" driverName="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/auth" connectionName="con_name" connectionPassword="con_pass"
userTable="users" userNameCol="user_name" userCredCol="user_pass" userRoleTable="user_roles" roleNameCol="role_name" />
    </Engine>
  </Service>

I checked Driver name and path, DB-port, DB-name, DB-Table-. and -column-names, I think tthe settings are OK.
Why "ajp13 listening on /0.0.0.0:8009" ? Is this normal?
Why are there no entries in catalina.out, localhost_log?  Catalina_log has a size of 0 bytes.
DB-access has root-permissions.

Where do I make the mistake ?


----- Original Message ----- 
From: "David Short" <ds...@san.rr.com>
To: "'Tomcat Users List'" <us...@tomcat.apache.org>
Sent: Wednesday, April 25, 2007 1:35 AM
Subject: RE: Tomcat UserDB in MySQL


Add a realm under the <Engine name="Catalina" defaultHost="localhost">
section.

You'll need to copy the correct MySQL JDBC driver
(http://dev.mysql.com/downloads/connector/j/5.0.html) to the
tomcat_home\common\lib directory.  Replace the "test" in localhost:3306/test
with you database name.

I've got it running on Tomcat 5.5.23 and MySQL 5.1.


      <Realm  className="org.apache.catalina.realm.JDBCRealm"
             driverName="com.mysql.jdbc.Driver"
          connectionURL="jdbc:mysql://localhost:3306/test" debug="99"
         connectionName="root" connectionPassword="password"
              userTable="users" userNameCol="username" userCredCol="pass"
          userRoleTable="roles" roleNameCol="role" />

-----Original Message-----
From: waynel@web.de [mailto:waynel@web.de] 
Sent: Tuesday, April 24, 2007 4:26 PM
To: Tomcat Users List
Subject: Tomcat UserDB in MySQL

I want to replace the "tomcat-users.xml" with two tables in MySQL:

Database : auth
table users :    username varchar(15) primary key NN
                    pass varchar(41) NN

table roles :     username varchar(15) primary key NN
                    role varchar(10) NN

Tried the solution from thread "[SOLVED] :) user authetication on MySql db
issue need some help!"
from the list, but still doesn´t work.

Are there any more changes I have to make.
Do I need to update TC (now using TC 5.0.28) I want to avoid an update,
because everything else is running fine, and I made the experience that
updates often change this.

The TC admintool doesn´t  give the possibility to add MySQL userDBs.

Thanks




---------------------------------------------------------------------
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: Tomcat UserDB in MySQL

Posted by David Short <ds...@san.rr.com>.
Add a realm under the <Engine name="Catalina" defaultHost="localhost">
section.

You'll need to copy the correct MySQL JDBC driver
(http://dev.mysql.com/downloads/connector/j/5.0.html) to the
tomcat_home\common\lib directory.  Replace the "test" in localhost:3306/test
with you database name.

I've got it running on Tomcat 5.5.23 and MySQL 5.1.


      <Realm  className="org.apache.catalina.realm.JDBCRealm"
             driverName="com.mysql.jdbc.Driver"
          connectionURL="jdbc:mysql://localhost:3306/test" debug="99"
         connectionName="root" connectionPassword="password"
              userTable="users" userNameCol="username" userCredCol="pass"
          userRoleTable="roles" roleNameCol="role" />

-----Original Message-----
From: waynel@web.de [mailto:waynel@web.de] 
Sent: Tuesday, April 24, 2007 4:26 PM
To: Tomcat Users List
Subject: Tomcat UserDB in MySQL

I want to replace the "tomcat-users.xml" with two tables in MySQL:

Database : auth
table users :    username varchar(15) primary key NN
                    pass varchar(41) NN

table roles :     username varchar(15) primary key NN
                    role varchar(10) NN

Tried the solution from thread "[SOLVED] :) user authetication on MySql db
issue need some help!"
from the list, but still doesn´t work.

Are there any more changes I have to make.
Do I need to update TC (now using TC 5.0.28) I want to avoid an update,
because everything else is running fine, and I made the experience that
updates often change this.

The TC admintool doesn´t  give the possibility to add MySQL userDBs.

Thanks




---------------------------------------------------------------------
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