Reputation: 33
**I wanted to configure Tomcat6.0 authentication via JDBC realm Configuration.**** I checked following:
-All my "users" and "roles" are stored in MySQL database.
-MySQL JDBC drives are in tomcat\lib directory
-Tomcat-user-xml is modified for such realm as below
<-Realm className="org.apache.catalina.realm.JDBCRealm" driverName="org.gjt.mm.mysql.Driver" connectionName="XXX" connectionPassword="YYY" connectionURL="jdbc:mysql://localhost/mydb" digest="MD5" userTable="users" userNameCol="username" userCredCol="password" userRoleTable="user_roles" roleNameCol="rolename"/>
After doing this whenever I try to run Tomcat and try to run 'Manager' then it throws Authentication error on browser and Catalina.log contain following error log everytime.
SCHWERWIEGEND: Exception opening database connection java.sql.SQLException: Access denied for user 'XXX';password=XXXX'@'localhost' (using password: NO) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3558) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3490) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919) at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3996) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1284) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2142) at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:781) at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:46) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:284) at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:703) at org.apache.catalina.realm.JDBCRealm.start(JDBCRealm.java:775) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1037) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:583) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Please anybody have idea what is going wrong and at which point.
Thanks
Upvotes: 1
Views: 3668
Reputation: 1
I had the same problem when my server.xml was the following:
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/authorization"
connectionName="root"
connectionPassword="xxxxx"
userTable="user_table"
userNameCol="user"
userCredCol="password"
userRoleTable="role_table"
roleNameCol="role" />
but finally I found it was wrong in tomcat7, it should be:
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/authorization?user=root&password=xxxxxx"
userTable="user_table"
userNameCol="user"
userCredCol="password"
userRoleTable="role_table"
roleNameCol="role" />
Upvotes: 0
Reputation: 11
use it as:
<Realm className="org.apache.catalina.realm.JDBCRealm"
connectionURL="jdbc:mysql://localhost/mydb?user=XXX&password=YYY"
driverName="com.mysql.jdbc.Driver"
...
rest same as before/>
Upvotes: 1
Reputation: 104188
From the exception it seems that the username and/or password of the database user are incorrect. Make sure that they are spelled right and that a database user with the proper access rights is actually created.
Upvotes: 0