On 21/02/2017 13:31, Martin Knoblauch wrote:
> Hi,
> 
>  is there a way to find the absolute path of the application root before
> the servlet is initialized?
> 
> Alternatively: is there a way to defer the initialization of a datasource
> until the servlet is initialized?
> 
> Background: I have extended "org.apache.tomcat.jdbc.pool.DataSourceFactory"
> to automatically set credentials so that they are not stored in the
> "Catalina/localhost/XXX.xml" file. Instead they are taken from encrypted
> values in a file below the application root. Works fine if I know that path
> at "createDataSource" time.

And the decryption key for that file is stored where?

https://wiki.apache.org/tomcat/FAQ/Password

> In order to avoid hard coding that path, I need a programmatic to find that
> value. Unfortunately the datasource is initialized before the servlet, so
> "getRealPath()" is not working yet.
> 
> Environment is Tomcat 8 plus JDK 8. Plus an commercial application that I
> do not want to name :-)

Ignoring what I suspect is a fundamental flaw in this plan, you probably
want a ServletContextListener and contextInitialized()

Mark



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to