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) 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) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 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="xxxxxx" 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="20000" 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 jar into $CATALINA_HOME/common/lib. > > Ok. > > > I already created the database with the required tables user, > > user-roles and roles. > > Ok. > > > 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. > > So you have a JNDI data source configured in server.xml? Does it need > to be global? If not, put it into your webapp in META-INF/context.xml > > > I configured the <security-constraint> on the web.xml > > Ok. > > > I added the <resource-ref> to the jdbc/oaso into the web.xml > > Good. If you configure your DataSource in context.xml, you don't need > this step, though I don't think it hurts. > > So... how doesn't it work? > > Do you get an exception? If so, give us the stack trace. > > Do you get a log message? If so, give us the message. > > You still haven't described what is wrong. For all I can tell, it's > working. <shrug> > > - -chris > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.7 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFGVeve9CaO5/Lv0PARArGuAJ90ugIycb6XnBc1UFDjDoaLs+WWygCfXRuW > qidBk4elye0qqFm4W4eDurw= > =7mX9 > -----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] --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]