Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 80449 invoked from network); 4 Dec 2010 17:42:23 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 4 Dec 2010 17:42:23 -0000 Received: (qmail 58279 invoked by uid 500); 4 Dec 2010 17:42:19 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 58178 invoked by uid 500); 4 Dec 2010 17:42:19 -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 58169 invoked by uid 99); 4 Dec 2010 17:42:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Dec 2010 17:42:19 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RFC_ABUSE_POST,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [98.139.52.217] (HELO nm20.bullet.mail.ac4.yahoo.com) (98.139.52.217) by apache.org (qpsmtpd/0.29) with SMTP; Sat, 04 Dec 2010 17:42:12 +0000 Received: from [98.139.52.191] by nm20.bullet.mail.ac4.yahoo.com with NNFMP; 04 Dec 2010 17:41:50 -0000 Received: from [98.139.52.187] by tm4.bullet.mail.ac4.yahoo.com with NNFMP; 04 Dec 2010 17:41:50 -0000 Received: from [127.0.0.1] by omp1070.mail.ac4.yahoo.com with NNFMP; 04 Dec 2010 17:41:50 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 838258.91757.bm@omp1070.mail.ac4.yahoo.com Received: (qmail 29722 invoked by uid 60001); 4 Dec 2010 17:41:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1291484510; bh=GzWeOIP48MELKzn2vgqNDgeHFFy9L06t+uYuxsoqtsc=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=dlnsf4TTEraOO4xS82bkTYawM76ompkTHQh43MbcBLt5AbGtkMfeK3h+QQejwjRV9O2ZIpDerGYh8czyo3kYkMv1A4HLPDZYBZnVNAN/T0e46yRRXPrx95jbP2YZWm9O+7d7nWDeMcvl3kdnOlyNONZbogV/aCf37tF222UN+tw= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=qTpajHDmt05djXvUKBaQVshPrcCWKJQgLMI8riocJPUU1gyJ/H2iK34H7OhRgjAXKVFlIrEySmYzvpPRj7e2BC5p/FaaxWl2T/ZJ7ZHKkikLI9d96TxlP5MbJz0y3eKqIJtaunWYMa/PoBZ/0y3sHCQyuZm8Zm40s/cRWlkmirw=; Message-ID: <706826.29507.qm@web56604.mail.re3.yahoo.com> X-YMail-OSG: 2vPCNBEVM1lCLOul74lDOTnMIf5SPOZcllnNpCcKk2Op2KB FwpcIronKJe1P8UCoF5f_YmIRBE_bbzpbe5PpsuMRU1JEqnCVGZZWrJJK5s5 kQn4uxfNmuu6ad3R2dnBiC4oRrFcn.tSnnTXS5emZ7K6g1tAy5jQiKZAbGD_ WVS7gwyt1fYyreFzFaMHZjwu8nyLj_s7wz_1sHDe5AI_qEDjy9akLvtUrKt4 ghmieU6COBN3l4OCXUomZU7wyNTQD27oQo_jWOIkOTG0tqnipHsGFLxUWOzt 9KdbGsVKKY4phCUi_Qgf2jVxjWzZI7Aflwy9XssEKCyP_KHE3_L1kN.jh3Es ZW46lmHntHuqt5Iu6 Received: from [71.133.241.161] by web56604.mail.re3.yahoo.com via HTTP; Sat, 04 Dec 2010 09:41:50 PST X-Mailer: YahooMailRC/553 YahooMailWebService/0.8.107.285259 References: <30366628.post@talk.nabble.com> Date: Sat, 4 Dec 2010 09:41:50 -0800 (PST) From: Mark Eggers Subject: Re: Place .ini conf file inside the war package. To: Tomcat Users List In-Reply-To: <30366628.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Read about using properties files. They're typically called .properties. Snippet of code that can be placed in a ServletContextListener. String resource = "some.properties"; InputStream in = this.getClass().getClassLoader().getResourceAsStream(resource); try { props.load(in); in.close(); } catch (IOException ex) { ex.printStackTrace(); // ugly } Note that this is not a complete ServletContextListener. Normally I create a separate class, have that class's constructor read the properties file, and then use the ServletContextListener to create a servlet context attribute with the information. You can use an init parameter to read the resource name from web.xml, and then pass that information to your class as an argument to the constructor. Catch exceptions (such as file not found) appropriately. The Apache commons configuration (mentioned in another message) provides a lot of nice tools for reading properties files. Place the some.properties file in src/main/resources of your Maven project. This will get it packed up in WEB-INF/classes of your war file once you run maven package. Read the javadoc on Class.getResourceAsStream() concerning how to locate the properties file. . . . . just my two cents. /mde/ ----- Original Message ---- From: srd.pl To: users@tomcat.apache.org Sent: Sat, December 4, 2010 3:58:25 AM Subject: Place .ini conf file inside the war package. Hello, I have a quick question considering my rest webservice. I would like to place an .ini file with configuration parameters inside an war file, so that I can change them wile the app is deployed on tomcat without recompiling. Can any give an advice on how to do this? And how to open this file (what path) in my java code. I am using maven so an advice on how to write a special script in the pom.xml file would be great. -- View this message in context: http://old.nabble.com/Place-.ini-conf-file-inside-the-war-package.-tp30366628p30366628.html Sent from the Tomcat - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org