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 78466200C23 for ; Wed, 22 Feb 2017 13:12:08 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 76D56160B67; Wed, 22 Feb 2017 12:12:08 +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 C0812160B49 for ; Wed, 22 Feb 2017 13:12:07 +0100 (CET) Received: (qmail 2780 invoked by uid 500); 22 Feb 2017 12:12:06 -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 2769 invoked by uid 99); 22 Feb 2017 12:12:06 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Feb 2017 12:12:06 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id C7B5A1A00AD for ; Wed, 22 Feb 2017 12:12:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.18 X-Spam-Level: * X-Spam-Status: No, score=1.18 tagged_above=-999 required=6.31 tests=[DKIM_ADSP_CUSTOM_MED=0.001, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id DeZYa3omLuMp for ; Wed, 22 Feb 2017 12:12:04 +0000 (UTC) Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 64FD45F5C9 for ; Wed, 22 Feb 2017 12:12:04 +0000 (UTC) Received: by mail-wm0-f41.google.com with SMTP id v186so138578919wmd.0 for ; Wed, 22 Feb 2017 04:12:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=H4sXwcb/xpZ2VbZNcYkFYiHIUdxPs9CncAff/Z/fCKY=; b=OjiraObzqJNVmnGmX1Ay2JBuAFbDJvtUdJT7RUb2U/jLw7x3qyuQrZCk3jy/eqSO+u RNJVt53dOYEmGN2ETp0/YZceEohpLfhXyDjUmTbFTuyo8+2vWdh7RM6mGw1m27nHZ0QF 8if64aR5KLtc3Hz+hmlpE1We/S1a9nv5MpUcFrhCdWmN4Bf03h6ZfQX5PyQx6O6s3uPU DgyZkYsJLoQYssMqq1AQUgQRbdjrAjOoXD/CRH6Q9ogEpOTlHo8FSTB0B9F9bIodDR3O 0L9deAXz2sevc81FBCD7NXgFFGVOokqF99w325pMMj9dOSfWATDaSAlVr3AM+9bQ6bO/ Ur+g== X-Gm-Message-State: AMke39k4gtMoLvhmc7HO49BTBd4ypUYfQ9fay5HAjEf89bIK1+C9Yqq0V3IB+I6tZUrTrw== X-Received: by 10.28.32.198 with SMTP id g189mr2061853wmg.37.1487765517908; Wed, 22 Feb 2017 04:11:57 -0800 (PST) Received: from [134.225.100.30] (catbells.rdg.ac.uk. [134.225.100.30]) by smtp.gmail.com with ESMTPSA id e6sm1515081wrc.30.2017.02.22.04.11.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Feb 2017 04:11:57 -0800 (PST) Subject: Re: Getting application root path before servlet is initialized? To: Tomcat Users List References: From: =?UTF-8?Q?Antonio_S._Cofi=c3=b1o?= Message-ID: <160d9d46-39c1-324f-1ba8-17800f2d8501@gmail.com> Date: Wed, 22 Feb 2017 12:11:56 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit archived-at: Wed, 22 Feb 2017 12:12:08 -0000 Dear Martin, On 21/02/17 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. > > 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 :-) > > Thanks in advance > Martin For this purpose I use the ant properties interpolation on tomcat configuration xml-files http://tomcat.apache.org/tomcat-7.0-doc/config/index.html It may be you requirements needs a more elaborated solution, but this a convenient way to do it. Regards Antonio --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org