Discussions

Web tier: servlets, JSP, Web frameworks: problem with tomcat JDBC realm , i can not login and all ?

  1. Hi Thank you for reading my post i have problem with tomcat JDBC realm I defined a jdbc realm in server.xml also i configured my application to use Realms but it never login into system ,it always send me to login_error page instead of logging in to the syste. I should say that when i creaete my own realm in server.xml ,i can not login into admin console anymore. are these two relevant ? should i comment or uncomment more stuff in server.xml ? how an application knows which realm it should use ? another question that i have is about users / users_role / roles tables should i create all these tables ?my users allways has one role , so i create one table and it contains also role column , i mapped these in server.xml . can it be a problem for tomcat ? is it manedatory to use 3 tables ? I attached my web.xml section that is related to security and also server.xml section that is related to security and realms I should say that i double check JDBC driver to be in place , double check connection url ... thank you very much. -------------web.xml begin---------------- all *.jsp manager user NONE FORM /login.html /login_error.html manager user ---------------server.xml---------- <!-- Because this Realm is here, an instance will be shared globally --> <!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. --> <!-- by masoud <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> --> <!-- Comment out the old realm but leave here for now in case we need to go back quickly --> <!-- <Realm className="org.apache.catalina.realm.MemoryRealm" /> --> <!-- Replace the above Realm with one of the following to get a Realm stored in a database and accessed via JDBC --> <!-- <Realm className="org.apache.catalina.realm.JDBCRealm" driverName="org.gjt.mm.mysql.Driver" connectionURL="jdbc:mysql://localhost/authority" connectionName="test" connectionPassword="test" userTable="users" userNameCol="user_name" userCredCol="user_pass" userRoleTable="user_roles" roleNameCol="role_name" /> --> <!-- <Realm className="org.apache.catalina.realm.JDBCRealm" driverName="sun.jdbc.odbc.JdbcOdbcDriver" connectionURL="jdbc:odbc:CATALINA" userTable="users" userNameCol="user_name" userCredCol="user_pass" userRoleTable="user_roles" roleNameCol="role_name" /> --> ------------Database table structure--------- CREATE TABLE "HR"."USERS" ( "NAME" VARCHAR2(32 CHAR), "USER_ID" NUMBER, "LASTNAME" VARCHAR2(32 CHAR), "USERNAME" VARCHAR2(32 CHAR), "PASSWORD" VARCHAR2(32 CHAR), "ROLE_NAME" VARCHAR2(128 CHAR), CONSTRAINT "USERS_PK" PRIMARY KEY ("USER_ID") ENABLE ) ;
  2. For details : http://tomcat.apache.org/tomcat-5.5-doc/realm-howto.html#JDBCRealm snippet from tomcat 5 documentation There is substantial configuration flexibility that lets you adapt to existing table and column names, as long as your database structure conforms to the following requirements: There must be a table, referenced below as the users table, that contains one row for every valid user that this Realm should recognize. The users table must contain at least two columns (it may contain more if your existing applications required it): Username to be recognized by Tomcat when the user logs in. Password to be recognized by Tomcat when the user logs in. This value may in cleartext or digested - see below for more information. There must be a table, referenced below as the user roles table, that contains one row for every valid role that is assigned to a particular user. It is legal for a user to have zero, one, or more than one valid role. The user roles table must contain at least two columns (it may contain more if your existing applications required it): Username to be recognized by Tomcat (same value as is specified in the users table). Role name of a valid role associated with this user Bhagvan K http://www.jroller.com/page/bhagvank