Chris,
Thanks for you time. Your response goes a long way to explaining why there is 
so little specific information on embedding tomcat.
Really, just as I said.  I had convinced myself from several items encountered 
on the web that an embedded tomcat instance would not read the standard 
conf/*.xml.  If I hit any of those pages again I will react (either on the page 
or perhaps post here, if that would be appropriate).  

TL/DR: at heart I’m struggling with the proper initialization and consumption 
of the dbpc2 datasource which I add programmatically and might consider using 
the context.xml version.  A litany of small issues:
My @Resource(name, type) Datasource ds” doesn’t take (I have several more 
attempts planned)
Is that failure logged?
Is context.lookup() expensive?
Is there any configuration available only in xml? 
DriverManager is working fine but it that the best access to the DataSource, 
which I need to be able to change the current database (in a postgres sense)


> On Dec 3, 2020, at 8:06 AM, Christopher Schultz 
> <ch...@christopherschultz.net> wrote:
> 
> Rob,
> 
> On 12/2/20 13:31, Rob Sargent wrote:
>> I'm old and easily confused: does an embedded tomcat server read (any) 
>> context.xml file?  I find conflicting answers /out there./
>> Using tomcat 9.0.40
>>    embeddedTomcat =new Tomcat();
>>    embeddedTomcat.setPort(tomcatPort);
>>    embeddedTomcat.enableNaming();
>>    embeddedTomcat.getConnector();// an init, really String contextRootPath 
>> =System.getenv("CATALINA_HOME");
>>    Context contextTomcat =embeddedTomcat.addContext("",new 
>> File(contextRootPath +"/sgs").getAbsolutePath());
>> I know it is finding WEB-INF/web.xml (under "sgs") and finds all my 
>> servlets, none of which are named in the web.xml.
> 
> Tomcat should be reading your web application's META-INF/context.xml file, if 
> one exists.
> 
> If you call Tomcat.init(), it will attempt to locate the default 
> conf/server.xml, conf/web.xml, and conf/context.xml based upon your 
> configuration source.
> 
> What are you /really/ asking?
> 
> -chris
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
> 

Reply via email to