Created attachment 35191 [details] Properly set the TCCL before performing JNDI datasource lookups When attempting to utilize a JNDI datasource defined at the Context level, JDBCStore uses the wrong TCCL and the lookup fails. The fix for this (patch attached against current 8.5.x-trunk (revision 1803599) is similar to the changes introduced by revisions 1514281 and 1726925: the JDBCStore session store implementation correctly sets the TCCL to that of the webapp context before attempting to load a session from the database. It should do the same before attempting the JNDI datasource lookup.
Created PR at https://github.com/apache/tomcat/pull/71 Updating patch to reflect the PR changes, backported to 8.5.x-trunk.
Created attachment 35192 [details] Properly set the TCCL before performing JNDI datasource lookups
The patch forces a switch from a global DataSource to a local one. That is going to break configurations for anyone currently using this Store. I think what is required is something similar to the DataSourceRealm's localDataSource attribute that allows either to be used.
Created attachment 35194 [details] Set TCCL to the webapp classloader if localDataSource == true
Thanks Mark, the patch and PR have been modified to reflect your recommendation.
Many thanks. I added some docs and a change log entry and applied it. Fixed in: - trunk for 9.0.0.M26 onwards - 8.5.x for 8.5.20 onwards - 8.0.x for 8.0.46 onwards I didn't back-port to 7.0.x because the back-port was not clean and it seems unlikely that anyone already using 7.0.x is going to need this option.