tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ubk <m.urbanow...@o2.pl>
Subject JDBCRealm, Tomcat and MySQL
Date Sat, 02 May 2009 18:29:50 GMT

Hi all
I have a problem with authorization based on JDBCRealm. When I'm trying to
get access to some html page which is store in protected directory all that
I can see is just login-error.jsp page. I'm using login and password from my
database.


My server.xml:
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
    <Listener className="org.apache.catalina.core.AprLifecycleListener"
SSLEngine="on" />
    <Listener className="org.apache.catalina.core.JasperListener" />
     <Listener
className="org.apache.catalina.mbeans.ServerLifecycleListener" />
    <Listener
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

    <GlobalNamingResources>
        <Resource name="jdbc/MySQL" auth="Container"
type="javax.sql.DataSource"/>
        <ResourceParams name="jdbc/MySQL">
            <parameter>
                <name>factory</name>
               
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
            </parameter>
            <parameter>
                <name>maxActive</name>
                <value>10</value>
            </parameter>
            <parameter>
                <name>maxIdle</name>
                <value>5</value>
            </parameter>
            <parameter>
                <name>validationQuery</name>
                <value>SELECT 1</value>
            </parameter>
            <parameter>
                <name>testOnBorrow</name>
                <value>true</value>
            </parameter>
            <parameter>
                <name>testWhileIdle</name>
                <value>true</value>
            </parameter>
            <parameter>
                <name>timeBetweenEvictionRunsMillis</name>
                <value>10000</value>
            </parameter>
            <parameter>
                <name>minEvictableIdleTimeMillis</name>
                <value>60000</value>
            </parameter>
            <parameter>
                <name>username</name>
                <value>root</value>
            </parameter>
            <parameter>
                <name>password</name>
                <value>ubk</value>
            </parameter>
            <parameter>
                <name>driverClassName</name>
                <value>com.mysql.jdbc.Driver</value>
            </parameter>
            <parameter>
                <name>url</name>
                <value>jdbc:mysql://localhost:3306/wypozyczalnia</value>
            </parameter>
        </ResourceParams>
    </GlobalNamingResources>

    <Service name="Catalina">
        <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000" 
               redirectPort="8443" />
        <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
        <Engine name="Catalina" defaultHost="localhost">
    
            <Realm className="org.apache.catalina.realm.JDBCRealm"
debug="99"
		driverName="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/wypozyczalnia"
connectionName="root"
		connectionPassword="ubk" userTable="tomcat_users"
		userNameCol="user_name" userCredCol="user_pass"
		userRoleTable="tomcat_roles" roleNameCol="role_name" /> 

            <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

            </Host>
        </Engine>
    </Service>
</Server>


My webapp web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <session-config>
        <session-timeout>5</session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <security-constraint>
        <display-name>WstepWzbroniony</display-name>
        <web-resource-collection>
            <web-resource-name>pliki</web-resource-name>
            <url-pattern>/pliki/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>admin</role-name>
        </auth-constraint>
    </security-constraint>
    <login-config>
        <auth-method>FORM</auth-method>
        <realm-name/>
        <form-login-config>
            <form-login-page>/login.jsp</form-login-page>
            <form-error-page>/login-error.jsp</form-error-page>
        </form-login-config>
    </login-config>
    <security-role>
        <description/>
        <role-name>admin</role-name>
    </security-role>
</web-app>

I have no idea what's wrong. It's my first time with sth bigger in webapps.
I'm rookie.
I'm using Netbeans. 
-- 
View this message in context: http://www.nabble.com/JDBCRealm%2C-Tomcat-and-MySQL-tp23349009p23349009.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Mime
View raw message