well, I couldn't get a Realm to function when the DataSource it needed was
defined in the same Context as the Realm itself. 

I've made it work by declaring the datasource resource in the 'global naming
resources' section of server.xml, and the realm directly under the 'engine'
element. And then in my host, I use a resourcelink to reference (and rename)
the globalresource to what my application is expecting. 

still puzzled why I couldn't get the other setup to work. 


> -----Original Message-----
> From: GB Developer [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, October 20, 2005 9:56 AM
> To: 'Tomcat Users List'
> Subject: RE: Trouble finding Datsource Resource with DataSourceRealm
> 
> 
> I should have mentioned, I have a ContextListener that contains the
> following:
> 
> -----------------------------------------------------------
> initCtx = new InitialContext();
> envCtx  = (Context) initCtx.lookup("java:comp/env");
> 
> logger.info("*** loading Data Source");
> try {
>       ds = (DataSource) envCtx.lookup("sql/DataSource");
>       application.setAttribute("services.datasource", ds);
>       logger.info("*** DataSource loaded @ services.datasource");
> } catch (NamingException ne) {
>       logger.fatal("ERROR loading DataSource: ", ne);
> }
> -----------------------------------------------------------
> 
> And I get both 'info' messages.  So the DataSource resource 
> is being loaded,
> and it *can* be found at "sql/DataSource" (by my code in the context
> listener).  It's just the Realm that can't seem to find it, 
> as indicated by
> the stacktrace below.
> 
> However, leaving no stone un-turned, I deleted the entire 
> work directory for
> the 'foo' host and get the same result. 
> 
> 
> This still appears in the engine log when I attempt to authenticate: 
> 
> 2005-10-20 09:51:15 DataSourceRealm[]: Exception performing 
> authentication
> javax.naming.NameNotFoundException: Name sql is not bound in 
> this Context
>   at org.apache.naming.NamingContext.lookup(NamingContext.java:768)
>   at org.apache.naming.NamingContext.lookup(NamingContext.java:151)
>   at
> org.apache.catalina.realm.DataSourceRealm.open(DataSourceRealm
> .java:437)
>   at
> org.apache.catalina.realm.DataSourceRealm.authenticate(DataSou
> rceRealm.java:
> 277)
>   at
> org.apache.catalina.authenticator.BasicAuthenticator.authentic
> ate(BasicAuthe
> nticator.java:129)
> 
> 
> 
> > -----Original Message-----
> > From: Stanley Bradbury [mailto:[EMAIL PROTECTED] 
> > Sent: Wednesday, October 19, 2005 8:07 PM
> > To: Tomcat Users List
> > Subject: Re: Trouble finding Datsource Resource with DataSourceRealm
> > 
> < big snip />
> 
> > >
> > Hi -
> > I had a similar problem (with 5.5.12) that turned out to be 
> > related to 
> > restart persistence (see post 10/17 Subj: "Odd problem with Restart 
> > Persistance..." for more info).  You can do a quick test by 
> > deleting the 
> > SESSIONS.ser file in ...work/Catalina/localhost/<myWebApp> 
> > (or whatever 
> > name and host relates to your installation) - start Tomcat 
> and see if 
> > the datasource is found.  If so, you will want to disable restart 
> > persistance for this App (see my note for more info).
> > 
> > Hope this Helps
> > 
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to