You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ryan Palmer <ry...@hotmail.com> on 2018/12/18 06:26:14 UTC
How to use server.xml with embedded Tomcat 9?
Hello,
I'm using the Tomcat class to embed the container in my application. I have configured the CATLINA_HOME and _BASE properties, and I know those are working because the 'work' folder gets generated there as expected. However if I put a server.xml file in a 'conf' folder in the same directory, it does not seem to be loaded when calling Tomcat.init().
Documentation is very sparse on the Tomcat class so I am unsure how to configure it the "standard" way.
Thank you,
Ryan Palmer
Re: How to use server.xml with embedded Tomcat 9?
Posted by Rémy Maucherat <re...@apache.org>.
On Tue, Dec 18, 2018 at 7:33 AM Ryan Palmer <ry...@hotmail.com> wrote:
> Hello,
>
> I'm using the Tomcat class to embed the container in my application. I
> have configured the CATLINA_HOME and _BASE properties, and I know those are
> working because the 'work' folder gets generated there as expected. However
> if I put a server.xml file in a 'conf' folder in the same directory, it
> does not seem to be loaded when calling Tomcat.init().
>
> Documentation is very sparse on the Tomcat class so I am unsure how to
> configure it the "standard" way.
>
I very recently refactored Tomcat embedded (in Tomcat 9.0.14) to be more
flexible, with the main assumption that trying to replicate a complex
server.xml with Java code while keeping good configurability was a waste of
resources.
As for using it, there's "big jar" packaging (but with the important note
that it remains EE webapp based, rather than proprietary):
https://github.com/apache/tomcat/tree/trunk/res/tomcat-maven
Or you can do it yourself, you need to use
Tomcat.init(ConfigurationSource). You can use
startup.CatalinaBaseConfigurationSource to replicate the default Tomcat
behavior, or implement ConfigurationSource and have more flexibility. A few
components don't use that abstraction because they persist configs (JASPIC,
storeconfig).
Rémy