Re: Configuring a DataSourceRealm
Hello chris, Thanks again for the help.I will try to be more clear so that maybe you could help figure out what I am doing wrong. Like I said before I am trying to setup a DataSourceRealm to authenticate users by pull out the user information from a MySQL database. 1- I already created the tables and columns in my database that conforms to the requirements. 2 - I also configured a JNDI named jdbc/oaso on TomCat Server Administration. I tested this connection through a DBCP and it´s working fine. 3- I created a Realm inside the server.xml to use the JNDI jdbc/oaso between the Engine tags 4- I configured the security-constraint on the web.xml When I run the project I get the following error: 29/05/2007 12:23:55 org.apache.catalina.realm.DataSourceRealm open SEVERE: Exception performing authentication javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:769) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.catalina.realm.DataSourceRealm.open(DataSourceRealm.java:401) at org.apache.catalina.realm.DataSourceRealm.authenticate(DataSourceRealm.java:282) at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthenticator.java:180) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:619) The server.xml ?xml version=1.0 encoding=UTF-8? Server port=8025 Listener className=org.apache.catalina.core.AprLifecycleListener/ Listener className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener/ Listener className=org.apache.catalina.storeconfig.StoreConfigLifecycleListener/ Listener className=org.apache.catalina.mbeans.ServerLifecycleListener/ GlobalNamingResources Environment name=simpleValue type=java.lang.Integer value=30/ Resource name=jdbc/oaso type=javax.sql.DataSource maxActive=4 maxIdle=2 username=root maxWait=5000 driverClassName=com.mysql.jdbc.Driver password=xx url=jdbc:mysql://localhost:3306/renatovivacqua/ Resource auth=Container description=User database that can be updated and saved name=UserDatabase type=org.apache.catalina.UserDatabase factory=org.apache.catalina.users.MemoryUserDatabaseFactory pathname=conf/tomcat-users.xml/ /GlobalNamingResources Service name=Catalina Connector port=8084 redirectPort=8443 minSpareThreads=25 connectionTimeout=2 uRIEncoding=utf-8 maxSpareThreads=75 maxThreads=150 /Connector Connector port=8009 redirectPort=8443 protocol=AJP/1.3 /Connector Connector port=8443 scheme=https secure=true minSpareThreads=25 clientAuth=false maxSpareThreads=75 maxThreads=150 sslProtocol=TLS /Connector Engine defaultHost=localhost name=Catalina Realm className=org.apache.catalina.realm.UserDatabaseRealm/ Realm className=org.apache.catalina.realm.DataSourceRealm debug=99 dataSourceName=jdbc/oaso localDataSource=true userTable=users userNameCol=user_name userCredCol=user_pass userRoleTable=user_roles roleNameCol=role_name/ Host appBase=webapps autoDeploy=false liveDeploy=false name=localhost /Host /Engine /Service /Server On 5/24/07, Christopher Schultz [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Paulo, Paulo Vivacqua wrote: I copied the Mysql Driver's
Re: Configuring a DataSourceRealm
Hi David, Thanks for the help. I don´t have a reference to JNDI jdbc on my code. What I have is a login page with a form that´s sent to tomcat for authentication. form method=POST action=j_security_check input type=text name=j_username/br input type=password name=j_password/br input type=submit value=Enter / /form I restarted tomcat and what I am getting a login window for TomCat Manager Application. I tried using the a user and a password configured on tomcat-users but none of them work. the application error: do-dist: dist: F:\Paulo\ICESP\6sem\java\projetos\RealmJdbcTeste\nbproject\build-impl.xml:452: Deployment error: Access to Tomcat server has not been authorized. Set the correct username and password with the manager role in the Tomcat customizer in the Server Manager. See the server log for details. BUILD FAILED (total time: 57 seconds) the tomcat error 29/05/2007 14:39:23 org.apache.catalina.realm.DataSourceRealm open SEVERE: Exception performing authentication javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:769) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.catalina.realm.DataSourceRealm.open(DataSourceRealm.java:401) at org.apache.catalina.realm.DataSourceRealm.authenticate(DataSourceRealm.java:282) at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthenticator.java:180) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:619) On 5/29/07, David Short [EMAIL PROTECTED] wrote: In your code where you reference JNDI jdbc, reference jdbc/oaso instead. -Original Message- From: Paulo Vivacqua [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 29, 2007 8:37 AM To: Tomcat Users List Subject: Re: Configuring a DataSourceRealm Hello chris, Thanks again for the help.I will try to be more clear so that maybe you could help figure out what I am doing wrong. Like I said before I am trying to setup a DataSourceRealm to authenticate users by pull out the user information from a MySQL database. 1- I already created the tables and columns in my database that conforms to the requirements. 2 - I also configured a JNDI named jdbc/oaso on TomCat Server Administration. I tested this connection through a DBCP and it´s working fine. 3- I created a Realm inside the server.xml to use the JNDI jdbc/oaso between the Engine tags 4- I configured the security-constraint on the web.xml When I run the project I get the following error: 29/05/2007 12:23:55 org.apache.catalina.realm.DataSourceRealm open SEVERE: Exception performing authentication javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:769) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.catalina.realm.DataSourceRealm.open(DataSourceRealm.java:401) at org.apache.catalina.realm.DataSourceRealm.authenticate(DataSourceRealm.java: 282) at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthe nticator.java:180) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase .java:490) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126 ) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105 ) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processC onnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.jav a:527
Re: Configuring a DataSourceRealm
Hi David, The j_security_check is not a real page it´s a key for communicating with tomcat. I lookup all my code and there is no reference to JNDI jdbc. If I comment my Realm declaration on server.xml i get to the login page without any problem, and the authentication works, but the user info is retrieved from the tomcat-users file not from the database. I have my realm declaration placed right below the Realm className=org.apache.catalina.realm.UserDatabaseRealm/ on my server.xml. Is it in the right place? can I have both? thanks again On 5/29/07, David Short [EMAIL PROTECTED] wrote: Somewhere in your code, probably in j_security_check, there is a reference to a datasource, which will reference the JNDI value. You need to change that reference from jdbc to jdbc/oaso. -Original Message- From: Paulo Vivacqua [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 29, 2007 10:46 AM To: Tomcat Users List; [EMAIL PROTECTED] Subject: Re: Configuring a DataSourceRealm Hi David, Thanks for the help. I don´t have a reference to JNDI jdbc on my code. What I have is a login page with a form that´s sent to tomcat for authentication. form method=POST action=j_security_check input type=text name=j_username/br input type=password name=j_password/br input type=submit value=Enter / /form I restarted tomcat and what I am getting a login window for TomCat Manager Application. I tried using the a user and a password configured on tomcat-users but none of them work. the application error: do-dist: dist: F:\Paulo\ICESP\6sem\java\projetos\RealmJdbcTeste\nbproject\build-impl.xml:45 2: Deployment error: Access to Tomcat server has not been authorized. Set the correct username and password with the manager role in the Tomcat customizer in the Server Manager. See the server log for details. BUILD FAILED (total time: 57 seconds) the tomcat error 29/05/2007 14:39:23 org.apache.catalina.realm.DataSourceRealm open SEVERE: Exception performing authentication javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:769) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.catalina.realm.DataSourceRealm.open(DataSourceRealm.java:401) at org.apache.catalina.realm.DataSourceRealm.authenticate(DataSourceRealm.java: 282) at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthe nticator.java:180) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase .java:490) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126 ) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105 ) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processC onnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.jav a:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWo rkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav a:684) at java.lang.Thread.run(Thread.java:619) On 5/29/07, David Short [EMAIL PROTECTED] wrote: In your code where you reference JNDI jdbc, reference jdbc/oaso instead. -Original Message- From: Paulo Vivacqua [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 29, 2007 8:37 AM To: Tomcat Users List Subject: Re: Configuring a DataSourceRealm Hello chris, Thanks again for the help.I will try to be more clear so that maybe you could help figure out what I am doing wrong. Like I said before I am trying to setup a DataSourceRealm to authenticate users by pull out the user information from a MySQL database. 1- I already created the tables and columns in my database that conforms to the requirements. 2 - I also configured a JNDI named jdbc/oaso on TomCat Server Administration. I tested this connection through a DBCP and it´s working fine. 3- I created a Realm inside the server.xml to use the JNDI jdbc/oaso between the Engine tags 4- I configured the security-constraint on the web.xml When I run the project I get the following error: 29/05/2007 12:23:55 org.apache.catalina.realm.DataSourceRealm open SEVERE: Exception performing authentication javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:769) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.catalina.realm.DataSourceRealm.open(DataSourceRealm.java:401
Re: Configuring a DataSourceRealm
Hello Christopher, It worked. Thanks very much for the tips. have a nice day Paulo Vivacqua On 5/29/07, Propes, Barry L [EMAIL PROTECTED] wrote: I don't believe you can have both, Paulo...i believe it's one realm or the other if I'm not mistaken. -Original Message- From: Paulo Vivacqua [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 29, 2007 1:07 PM To: Tomcat Users List; [EMAIL PROTECTED] Subject: Re: Configuring a DataSourceRealm Hi David, The j_security_check is not a real page it´s a key for communicating with tomcat. I lookup all my code and there is no reference to JNDI jdbc. If I comment my Realm declaration on server.xml i get to the login page without any problem, and the authentication works, but the user info is retrieved from the tomcat-users file not from the database. I have my realm declaration placed right below the Realm className=org.apache.catalina.realm.UserDatabaseRealm/ on my server.xml. Is it in the right place? can I have both? thanks again On 5/29/07, David Short [EMAIL PROTECTED] wrote: Somewhere in your code, probably in j_security_check, there is a reference to a datasource, which will reference the JNDI value. You need to change that reference from jdbc to jdbc/oaso. -Original Message- From: Paulo Vivacqua [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 29, 2007 10:46 AM To: Tomcat Users List; [EMAIL PROTECTED] Subject: Re: Configuring a DataSourceRealm Hi David, Thanks for the help. I don´t have a reference to JNDI jdbc on my code. What I have is a login page with a form that´s sent to tomcat for authentication. form method=POST action=j_security_check input type=text name=j_username/br input type=password name=j_password/br input type=submit value=Enter / /form I restarted tomcat and what I am getting a login window for TomCat Manager Application. I tried using the a user and a password configured on tomcat-users but none of them work. the application error: do-dist: dist: F:\Paulo\ICESP\6sem\java\projetos\RealmJdbcTeste\nbproject\build-impl.xml:45 2: Deployment error: Access to Tomcat server has not been authorized. Set the correct username and password with the manager role in the Tomcat customizer in the Server Manager. See the server log for details. BUILD FAILED (total time: 57 seconds) the tomcat error 29/05/2007 14:39:23 org.apache.catalina.realm.DataSourceRealm open SEVERE: Exception performing authentication javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:769) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.catalina.realm.DataSourceRealm.open(DataSourceRealm.java:401) at org.apache.catalina.realm.DataSourceRealm.authenticate(DataSourceRealm.java: 282) at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthe nticator.java:180) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase .java:490) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126 ) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105 ) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processC onnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.jav a:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWo rkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav a:684) at java.lang.Thread.run(Thread.java:619) On 5/29/07, David Short [EMAIL PROTECTED] wrote: In your code where you reference JNDI jdbc, reference jdbc/oaso instead. -Original Message- From: Paulo Vivacqua [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 29, 2007 8:37 AM To: Tomcat Users List Subject: Re: Configuring a DataSourceRealm Hello chris, Thanks again for the help.I will try to be more clear so that maybe you could help figure out what I am doing wrong. Like I said before I am trying to setup a DataSourceRealm to authenticate users by pull out the user information from a MySQL database. 1- I already created the tables and columns in my database that conforms to the requirements. 2 - I also configured a JNDI named jdbc/oaso on TomCat Server Administration. I tested this connection through a DBCP and it´s working fine. 3- I created a Realm inside the server.xml to use the JNDI jdbc/oaso between
Configuring a DataSourceRealm
Hello there, I am having difficulty implementing a Datasource realm for my application. I followed some tutorials but could not make it to work.I already posted this issue on other forums but I got no answer. The application Instead of pulling out data from the MySQL database it´s getting the user information from the tomcat-users.xml (MemoryRealm) web.xml ?xml version=1.0 encoding=UTF-8? web-app version=2.4 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; session-config session-timeout 30 /session-timeout /session-config welcome-file-list welcome-file index.jsp /welcome-file /welcome-file-list security-constraint display-nameConstraint1/display-name web-resource-collection web-resource-nametesteJdbc/web-resource-name description/ url-pattern/index.jsp/url-pattern http-methodGET/http-method http-methodPOST/http-method http-methodHEAD/http-method http-methodPUT/http-method http-methodOPTIONS/http-method http-methodTRACE/http-method http-methodDELETE/http-method /web-resource-collection auth-constraint descriptionadmin/description role-nameadmin/role-name role-nametomcat/role-name role-namemember/role-name /auth-constraint user-data-constraint description/ transport-guaranteeCONFIDENTIAL/transport-guarantee /user-data-constraint /security-constraint security-constraint display-nameConstraint2/display-name web-resource-collection web-resource-namepagina1/web-resource-name description/ url-pattern/pagina1.jsp/url-pattern http-methodGET/http-method http-methodPOST/http-method /web-resource-collection auth-constraint description/ role-nameadmin/role-name role-namemember/role-name /auth-constraint user-data-constraint description/ transport-guaranteeCONFIDENTIAL/transport-guarantee /user-data-constraint /security-constraint login-config auth-methodFORM/auth-method realm-name/ form-login-config form-login-page/Login.jsp/form-login-page form-error-page/ErrorPage.jsp/form-error-page /form-login-config /login-config security-role description/ role-nameadmin/role-name /security-role security-role description/ role-nameguest/role-name /security-role security-role description/ role-namemember/role-name /security-role security-role description/ role-nametomcat/role-name /security-role resource-ref descriptionJdbcRealmTeste/description res-ref-namejdbc/oaso/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app server.xml ?xml version=1.0 encoding=UTF-8? Server Listener className=org.apache.catalina.mbeans.ServerLifecycleListener/ Listener className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener/ GlobalNamingResources Environment name=simpleValue type=java.lang.Integer value=30/ Resource name=jdbc/oaso type=javax.sql.DataSource/ Resource auth=Container description=User database that can be updated and saved name=UserDatabase type=org.apache.catalina.UserDatabase/ ResourceParams name=jdbc/oaso parameter namemaxWait/name value5000/value /parameter parameter namemaxActive/name value4/value /parameter parameter namepassword/name valueshisqi3320/value /parameter parameter nameurl/name valuejdbc:mysql://localhost:3306/renatovivacqua/value /parameter parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter namemaxIdle/name value2/value /parameter parameter nameusername/name valueroot/value /parameter /ResourceParams ResourceParams name=UserDatabase parameter namefactory/name valueorg.apache.catalina.users.MemoryUserDatabaseFactory/value /parameter parameter namepathname/name valueconf/tomcat-users.xml/value /parameter /ResourceParams /GlobalNamingResources Service name=Catalina Connector acceptCount=100 connectionTimeout=2 disableUploadTimeout=true maxSpareThreads=75 maxThreads=150 minSpareThreads=25 port=8080 redirectPort=8443 /Connector Connector port=8009
Re: Configuring a DataSourceRealm
Hello Chris, Thanks very much for your answer. Yes I am currently using MemoryRealm and I want to use DataSourceRealm instead. I am using tomcat 5.0 I copied the Mysql Driver's jar into $CATALINA_HOME/common/lib. I already created the database with the required tables user, user-roles and roles. I configured JNDI DataSource in Tomcat by adding a declaration for my resource named jdbc/oaso into a Context path to $CATALINA_HOME/conf/server.xml. I configured the security-constraint on the web.xml I added the resource-ref to the jdbc/oaso into the web.xml On 5/24/07, Christopher Schultz [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Paulo, Paulo Vivacqua wrote: I am having difficulty implementing a Datasource realm for my application. I followed some tutorials but could not make it to work.I already posted this issue on other forums but I got no answer. The application Instead of pulling out data from the MySQL database it´s getting the user information from the tomcat-users.xml (MemoryRealm) So... you are currently using MemoryRealm and you want to use DataSourceRealm instead? What version of Tomcat are you using? What have you tried already? Posting configuration without telling us what else you know isn't very helpful :( - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGVarm9CaO5/Lv0PARApCKAJ9T31kPWmqWi7Qqj+dKQCFZp44CegCfTOdL EQKleoWdZtWgU7j8lDzycPg= =G1yI -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Paulo Vivacqua [EMAIL PROTECTED] msn: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]