Chris, thank you for your reply

> -----Original Message-----
> From: Christopher Schultz [mailto:ch...@christopherschultz.net]
> Sent: 26 November 2014 04:17
> To: Tomcat Users List
> Subject: Re: How can code in a Realm gain access to a Globally Named
> Resource
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> Vince,
> 
> On 11/25/14 9:00 PM, vince.w...@thomsonreuters.com wrote:
> > Web applications gain access to Globally Named JDBC Resources
> > <GlobalNamingResources> by adding a <ResourceLink> to context.xml
> >
> > Then using code like:
> >
> > Context initContext = new InitialContext(); 
> > dbLookupStr = "java:comp/env/" + dbResourceName;
> > ds = (DataSource)initContext.lookup(dbLookupStr);
> >
> > HOW CAN code in a custom Realm gain access to 
> > one of those same Globally named database connection pools ?
> 
> What's wrong with the code above?

I don't know if there is nothing wrong with the code above,
if it can be used in a Realm, 
then what I'm missing is the Realm equivalent of 
adding a <ResourceLink> to an application's context.xml
As a result I fail to get a DataSource

I have the Realm defined in the <Engine> section of server.xml


> > Extra info included here for background: I have a custom realm that I
> > created by extending JDBCRealm it does its own authentication and
> > uses JDBCRealm's getRoles() to do the authorization. 
> > Although it works much
> > of the time, the inherited getRoles method causes problems. I've
> > decided to re-write my realm without extending JDBCRealm,  
> > thus I need
> > to write my own JDBC authorization code, hence the above question.
> 
> JDBCRealm should probably die, and you probably shouldn't be using it.
> 
> Why not extend DataSourceRealm instead? 
> You'll get DataSource access for free ;)

I've never looked at DataSourceRealm, perhaps it's time I did.
I used JDBCRealm because having used it years ago
I understand what it aims to do

> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
> Comment: GPGTools - http://gpgtools.org
> 
> iQIcBAEBCAAGBQJUdVRIAAoJEBzwKT+lPKRY8z4P/12ZMvXrmT4SJt/BLNhUJEMX
> j1rqGcZdKPH17pacMSfUMLciVvSLOZbsNoV2mgwUw+EfZVCUuL1i2Tk52vH2swa5
> l2pgQI0zJB2nREzP1jZLpnVXi2lB5L+GL2TV3WE7Mr+nG03lSCN3RB/4hUEdRgcU
> ZblJ5Dz62Jx/Vi+9d/qBYi68jSvgXLwQcrx+eFvYeKpTylSghkkn+mzbSgGW4RXL
> lfpMm+q+una4KpCCLZP40BWcGyx57loFakyucLjsuvDjKQmLbX8Ay4WU7R1sXX2O
> J+CZzzBqHOCU8Q9Snmt3xaYcZ+0De5UIYI17ztdKCD703a4evytwSXZ1tEpg3vYE
> lHNGIKcW/q6ABOt0eWxFTj/wjTCYn3rYhcv+mEPV0c6HPkJ9DqFKh0+efSnFsOnW
> CNWF9eH3Y64zmWh7DQ2AF+Aij4mtXof9YYl6Q6oAL4XBw8vMajwSek9dpXZYDKi0
> RkI5GhzWPP1xUx8FDfQfnfjJmHAKMIaK330EwX0RhJH9yoX+1vG5XCPT+/KV7Xfj
> ZCOz90SiPr2KxLAtijL79p98nWIB4w1GSNaN0z0ePrup1J+Kkfh2AqL4i/jmdXK8
> qQJ4TGJczgq6NZZbg+t6SkPA0nRN18f42Aq8yguwE7cYXb66rkfLUpxcqc28kdCO
> irKlHlgNrxDzSH0pwAM8
> =RqZF
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to