Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7C6B4200C25 for ; Fri, 24 Feb 2017 18:00:44 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 7B07C160B69; Fri, 24 Feb 2017 17:00:44 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C3A83160B62 for ; Fri, 24 Feb 2017 18:00:43 +0100 (CET) Received: (qmail 27121 invoked by uid 500); 24 Feb 2017 17:00:42 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 27109 invoked by uid 99); 24 Feb 2017 17:00:42 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Feb 2017 17:00:42 +0000 Received: from Christophers-MacBook-Pro.local (pool-173-66-116-184.washdc.fios.verizon.net [173.66.116.184]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 0C0D61A00A2 for ; Fri, 24 Feb 2017 17:00:41 +0000 (UTC) Subject: Re: Getting application root path before servlet is initialized? To: Tomcat Users List References: From: Christopher Schultz Message-ID: Date: Fri, 24 Feb 2017 12:00:41 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit archived-at: Fri, 24 Feb 2017 17:00:44 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Martin, On 2/21/17 8:31 AM, 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. Where are you configuring your ? In conf/server.xml or in your application's META-INF/context.xml file? > 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. getRealPath is a bad idea. Also, your DataSources will be fully-configured before any servlets are initialized, so it's too late. - -chris -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBCAAGBQJYsGa4AAoJEBzwKT+lPKRYSFEP/148R7SLCoXyYMyx8e5heN+J 3YwyJriefzfD1Y1t/X2koKmluaz4waOZgFdiJDEoGwdYiX0r9oD/IGk026vrO9pF 5o/RRGB/WioedqniPRrdosn9zObYnAea2HNgn2uYndlHioJ1KSR9xomlcYuAiW9+ ZCaKxCH+jmnh9OXmpV025pfips8Iga4EKGE2mtQI6yGW9chgy1v+PX+3usMy6b2L jE0koGCBQcnaQQHxDsFI3sUBmnY8nkQ80bCq21gQy+TEvFs7mZte1i+Zi+pgwlTe mZ4RpMebQUZzqeH8fmEHUwSuaphrP2O+xq07rWl/oXQCjEQGrlZJml2C9C6nS3Ds 2uhfclEz+Yhb3aw/iRtEHXWKnTa58PZ4Qtqlq9gDH3SYvIj+ancPKy3Wkv+K+dc8 ora7qKl97OoAcsAkKT0dL+psUcpepskw7EoCiEwPHeQKqSKOW1X0PXNVpHgZD2J4 kjX38PzFmtTjWj+wPa8cdZmD576iT8iiD4nClwON0dF6ipOY6R321GKmXPT2UUup YSmSO39WqKuehy5uhIK4EXs0XGlZU4y5ASPS0frdAv3SvxX7BqxKT1UJLbrEQFm6 QTJuFlZeRuPxEnsKpBMaEQtTrbwB3M9FTP/znrjCh7Bxq0TuMSafe2/nCXEFg201 jpJkYWzch8pZ2CKzU6Yw =d2oI -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org