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)
>         at
>
org.apache.catalina.realm.DataSourceRealm.authenticate(DataSourceRealm.java:
> 282)
>         at
> org.apache.catalina.authenticator.BasicAuthenticator.authenticate(Basi
> cAuthe
> nticator.java:180)
>         at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticat
> orBase
> .java:490)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.ja
> va:126
> )
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.ja
> va:105
> )
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValv
> e.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.pr
> ocessC
> onnection(Http11BaseProtocol.java:664)
>         at
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoi
> nt.jav
> a:527)
>         at
> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFoll
> owerWo
> rkerThread.java:80)
>         at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPo
> ol.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]
>
>


--
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]

Reply via email to