I'm sorry I'm a bit lost with all the information I had found on realm
configuration problems. Thanks in advance for any help.

I had read it could come from the version so I had tried on two different ones:

On my Vista version, I have the error "the name jdbc isn't bound to
the context".
I had tried  to use the datasource and mysql from a JSP page, it work
just fine when the security is off... So I guess my realm is wrong
somewhere... I had added the useNaming="true", the
localDataSource="true" and the autoReconnect="true" as adviced in
several threads though I still have the same troubles.

On my XP version, it seems better but when I use the right
login/password I have a HTTP 403 error message. I had only read it
could come from a wrong role-name so I had copied them directly from
mySQL and I still have the same problem... This version
reacts as expected with a false password.

Version 1 :

Windows Vista SP1
Tomcat 6.0.20
MySQL 5.1.35

To correct white page problems I had to use:
netsh int ip reset
netsh winsock reset
It might explain where my problems come from...

Here parts of the the main files used for security:

context.xml

<code>
<?xml version="1.0" encoding="ISO-8859-1"?>

<Context docBase="${app.name}" path="/CQC" privileged="true"
antiResourceLocking="false" antiJARLocking="false" debug="1"
reloadable="true" useNaming="true">
        <Resource       name="jdbc/authen"
                                auth="Container"
                                type="javax.sql.DataSource"
                                username="guillaume"
                                password="PASSWORD"
                                
url="jdbc:mysql://192.168.1.44:3306/securite_cqc?autoReconnect=true"
                                driverClassName="com.mysql.jdbc.Driver"
                                maxIdle="6000"
                                maxWait="1000"
                                maxActive="20000"
                                validationQuery="Select 1"
                                removeAbandonned="true"
                                removeAbandonnedTimeout="1000000"
                                logAbandonned="true" />

        <Realm  className="org.apache.catalina.realm.DataSourceRealm"
                        dataSourceName="jdbc/authen"
                        userTable="users"
                        userNameCol="user_name"
                        userCredCol="user_password"
                        userRoleTable="user_roles"
                        roleNameCol="role_name"
                        localDataSource="true"
                        autoReconnect="true"
                        debug="99"
                        digest="md5" />
</Context>

</code>

mySQL tables

<code>
mysql> select * from users;
+-----------+----------------------------------+
| user_name | user_password                    |
+-----------+----------------------------------+
| bruno     | md5password                      |
| essai     | md5password                      |
| franck    | md5password                      |
| guillaume | md5password                      |
| julien    | md5password                      |
| laurent   | md5password                      |
| noel      | md5password                      |
| tomcat    | md5password                      |
| virginie  | md5password                      |
+-----------+----------------------------------+
9 rows in set (0.00 sec)

mysql> select * from user_roles;
+-----------+----------------+
| user_name | role_name      |
+-----------+----------------+
| bruno     | utilisateur    |
| essai     | utilisateur    |
| franck    | utilisateur    |
| guillaume | administrateur |
| julien    | utilisateur    |
| laurent   | administrateur |
| noel      | utilisateur    |
| tomcat    | utilisateur    |
| virginie  | utilisateur    |
+-----------+----------------+
9 rows in set (0.00 sec)

</code>

web.xml

<code>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
        version="2.4">

        <security-constraint>
                <display-name>Securite sous Tomcat</display-name>
                <web-resource-collection>
                        <web-resource-name>Ressources 
protegees</web-resource-name>
                        <url-pattern>/Documentation/*</url-pattern>
                        <url-pattern>/Download/*</url-pattern>
                        <url-pattern>/FichierTest/*</url-pattern>
                        <url-pattern>/META-INF/*</url-pattern>
                        <url-pattern>/Statistiques/*</url-pattern>
                        <url-pattern>/Upload/*</url-pattern>
                        <url-pattern>/WEB-INF/*</url-pattern>
                        <url-pattern>*.jsp</url-pattern>
                        <http-method>GET</http-method>
                        <http-method>POST</http-method>
                </web-resource-collection>

    <auth-constraint>
                        <role-name>administrateur</role-name>
                        <role-name>utilisateur</role-name>
                </auth-constraint>

                <user-data-constraint>
                        <transport-guarantee>NONE</transport-guarantee>
                </user-data-constraint>
        </security-constraint>
        
        <security-role>
                <role-name>administrateur</role-name>
                <description>administrateur application</description>
        </security-role>

        <security-role>
                <role-name>utilisateur</role-name>
                <description>Utilisateur application</description>
        </security-role>

        <login-config>
                <auth-method>FORM</auth-method>
                <form-login-config>
                        <form-login-page>/Securite/login.jsp</form-login-page>
                        <form-error-page>/Securite/erreur.jsp</form-error-page>
                </form-login-config>
                <realm-name>Authentification pour Tomcat</realm-name>
        </login-config>
</web-app>

</code>

catalina.log

<code>
11 juin 2009 08:16:12 org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.16.
11 juin 2009 08:16:12 org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters
[false], random [true].
11 juin 2009 08:16:12 org.apache.coyote.http11.Http11AprProtocol init
INFO: Initialisation de Coyote HTTP/1.1 sur http-8080
11 juin 2009 08:16:12 org.apache.coyote.ajp.AjpAprProtocol init
INFO: Initializing Coyote AJP/1.3 on ajp-8009
11 juin 2009 08:16:12 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 808 ms
11 juin 2009 08:16:12 org.apache.catalina.core.StandardService start
INFO: Démarrage du service Catalina
11 juin 2009 08:16:12 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.20
11 juin 2009 08:16:12 org.apache.catalina.startup.HostConfig deployDescriptor
ATTENTION: A docBase C:\Program Files\Apache Software
Foundation\Tomcat 6.0\webapps\${app.name} inside the host appBase has
been specified, and will be ignored
11 juin 2009 08:16:13 org.apache.catalina.startup.HostConfig deployWAR
INFO: Déploiement de l'archive JavaBridgeTemplate5442.war de l'application web
11 juin 2009 08:16:13 org.apache.coyote.http11.Http11AprProtocol start
INFO: Démarrage de Coyote HTTP/1.1 sur http-8080
11 juin 2009 08:16:13 org.apache.coyote.ajp.AjpAprProtocol start
INFO: Starting Coyote AJP/1.3 on ajp-8009
11 juin 2009 08:16:13 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1125 ms
</code>

localhost.log

<code>
11 juin 2009 08:16:13 org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
11 juin 2009 08:16:13 org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
11 juin 2009 08:16:52 org.apache.catalina.realm.DataSourceRealm open
GRAVE: Exception performing authentication
javax.naming.NameNotFoundException: Le Nom jdbc n'est pas lié à ce Contexte
        at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
        at 
org.apache.catalina.realm.DataSourceRealm.open(DataSourceRealm.java:403)
        at 
org.apache.catalina.realm.DataSourceRealm.authenticate(DataSourceRealm.java:284)
        at 
org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:258)
        at 
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:417)
        at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at 
org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:427)
        at 
org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:384)
        at 
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1527)
        at java.lang.Thread.run(Unknown Source)
</code>

Windows XP SP3
Tomcat 6.0.16
MySQL 5.0.45

I had used the same configuration files with a distant database
instead of a local one and of course different IP adress... There
isn't any error in the log files beside the 403 error.

Thanks in advance for any reply

Guillaume

geama...@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to