Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EC640D18D for ; Sun, 9 Dec 2012 09:30:19 +0000 (UTC) Received: (qmail 16942 invoked by uid 500); 9 Dec 2012 09:30:16 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 16739 invoked by uid 500); 9 Dec 2012 09:30:15 -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 16699 invoked by uid 99); 9 Dec 2012 09:30:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Dec 2012 09:30:14 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of pid@pidster.com designates 209.85.214.173 as permitted sender) Received: from [209.85.214.173] (HELO mail-ob0-f173.google.com) (209.85.214.173) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Dec 2012 09:30:10 +0000 Received: by mail-ob0-f173.google.com with SMTP id xn12so2128157obc.18 for ; Sun, 09 Dec 2012 01:29:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pidster.com; s=google; h=references:from:in-reply-to:mime-version:date:message-id:subject:to :content-type:content-transfer-encoding; bh=0ARk+vuIyVWRafwYgp58CDJWNGWaOAabtGiN3Jrwdps=; b=kPRLluRL+ije8LY8pTSOCLXfj83pTMdbwMB6xDXRSm8NsMA266fU9lTAFiBUPYSZlC CJfKHLlafvPcfngUJElDJeAUTFQF5CyjK1+5x+b+4+LKQm/B0i5QzCE2stMAFpR3ReND 4y5Ot3fYW410FKem53X4hbQ342dyC/4FgcSbE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=references:from:in-reply-to:mime-version:date:message-id:subject:to :content-type:content-transfer-encoding:x-gm-message-state; bh=0ARk+vuIyVWRafwYgp58CDJWNGWaOAabtGiN3Jrwdps=; b=jGzuOFonY5C1vcYgmsLe7aXkJ0m26klVFrt460ryJMrP4Kj8k5bEQ1UwoMXMoC2HmW 2a1CVSndkbWmHoFNAbBJR4jfgAgzJQMVqXNoIMQQHMW7iweJR6BSEPbXdA0OdnQ4Ygl+ ijKIG0FJT/atxD7MactmeZglEEC8qoN3FMqZKEAxtVIQRKgU4egTeKq6i+wpLxISlil9 HtyKGsUZAdE25L+ID8o1wtgG7411kgbjbfA1fDVG1gdpd4ch2dGtKVQZxZY9TAqTxw09 MWNh3L7T00HhIctOv/hwcXWJs9R7VmsE8ck8iTJ2/Q2KrJdq/ID2qM57jwf2gZBcGXVj 6WPg== Received: by 10.182.98.19 with SMTP id ee19mr5684573obb.90.1355045389319; Sun, 09 Dec 2012 01:29:49 -0800 (PST) References: <1354898897.39776.YahooMailNeo@web193101.mail.sg3.yahoo.com> <50C25497.5060200@christopherschultz.net> <55AC0819-C0BB-445E-8689-A4D8E839D364@yahoo.co.in> <-1575792619315605313@unknownmsgid> <1354989518.16977.YahooMailNeo@web193101.mail.sg3.yahoo.com> <50C38CC6.4060608@yahoo.com> <1354996284.64515.YahooMailNeo@web193102.mail.sg3.yahoo.com> <50C3A56B.4060407@yahoo.com> From: "Pid *" In-Reply-To: Mime-Version: 1.0 (1.0) Date: Sun, 9 Dec 2012 09:31:30 +0000 Message-ID: <7833845704254080649@unknownmsgid> Subject: Re: Tomcat 6.0 CLASSPATH query To: Tomcat Users List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQlZGXIEQBq8YCZbqfzBa8/Wq8lnnX/dlcpPdWhNDog9ASmUtIIGGvPakA5VYptfjhW7HMV9 X-Virus-Checked: Checked by ClamAV on apache.org On 8 Dec 2012, at 20:57, "vicky007aggarwal@yahoo.co.in" wrote: > Thanks Mark > > Sorry for the confusion i created related to my requirements. > 5 Out of 6 requirements you stated below are correct. The last point i.e= $CATALINA_BASE is writable. I can manipulate/write files to this location. > So now do you have anything more to add to your proposed solution as you = suggested below 1. Please stop top-posting. 2. Put your resources in CATALINA_BASE/lib p > > > > Thanks, > Vicky > > > > On Dec 9, 2012, at 2:09 AM, Mark Eggers wrote: > >> See at the end for a truly spectacularly bad potential solution. Note th= at I have not tried this, so your mileage may vary. >> >> On 12/8/2012 11:51 AM, vicky wrote: >>> Thanks Mark for your valuable suggestions. >>> >>> But in my project i have a requirement to share one >>> "resource/properties file " across 10 applications deployed on single >>> tomcat instance >>> >>> We cannot afford to add the same properties file to all archives as >>> its contents keep changing. >>> >>> Another restriction which i have is that i cannot place any file >>> under "$CATALINA_HOME" directories , these are read only for us. >>> >>> Based on afore said concerns, do you have any better way out ..please >>> suggest. >>> >>> Appreciated all of your help >>> >>> Thanks for ur time Vicky >>> >>> >>> ________________________________ From: Mark Eggers >>> To: Tomcat Users List >>> Sent: Sunday, 9 December 2012 12:23 AM >>> Subject: Re: Tomcat 6.0 CLASSPATH query >>> >>> Comments inline below (a bit fuzzy from the move yet). >>> >>> On 12/8/2012 9:58 AM, vicky wrote: >>>> >>>> I have read the Tomcat 6.0 classloader documentation(below link), >>>> from this what i understood is that the >>>> "classes/jar/resource/properties file" get loaded from the >>>> following locations >>>> >>>> 1.Bootstrap classes of your JVM ($JAVA_HOME/jre/lib/ext). >>>> 2.System class loader classes ( Add bootstrap.jar & >>>> tomcat-juli.jar to CLASSPATH variable) 3.Common class loader >>>> classes ( refers $CATALINA_BASE/lib & $CATALINA_HOME/lib ) & uses >>>> $CATALINA_BASE/conf/catalina.properties 4. /WEB-INF/classes of >>>> your web application 5. /WEB-INF/lib/*.jar of your web application >>>> >>>> The thing which is still puzzling me is that how my >>>> "resource/properties files" get loaded to Tomcat CLASSPATH when i >>>> add them to "$CATALINA_BASE/bin" directory & When i move the same >>>> files to $CATALINA_BASE/conf directory then it doesn't get added to >>>> Tomcat CLASSPATH. >>>> >>>> My deployed applications need"properties/resource files ", Can >>>> someone please help me in understand the optimal way of adding >>>> these files to Tomcat CLASSPATH. Does placing the files under >>>> /bin is the right approach.Please suggest >>> >>> Why in the world are you adding these resource files to Tomcat's >>> CLASSPATH? If the resources are application - specific, you don't >>> need to do this at all. >>> >>> Just add the files to your local application. In Maven, there's a >>> special directory for that: >>> >>> src/main/resources >>> >>> In NetBeans, I normally create a separate package for all of my >>> configuration files. >>> >>> I think in Eclipse you'll have to make a subdirectory under >>> WEB-INF/classes and copy the files there. That's unpleasant. Eclipse >>> will include that in the build of the WAR file when you do an >>> "export". >>> >>> Then, just do the following in your code to reference the resource. >>> >>> InputStream in =3D >>> this.getClass().getClassLoader().getResourceAsStream(configfile); >>> >>> Where configfile is the complete classpath to your resource. >>> >>> This is nice. It works in exploded WARs, it works in WAR files, it >>> works in JARs. >>> >>> No mucking about with CLASSPATH. No polluting other applications or >>> Tomcat with spurious application - specific resources. This enables >>> you to run several copies of the same web application in the same >>> container, all with different configurations. >>> >>> Just search for getResourceAsStream() for more explanation. >>> >>>> In my organisation i cannot add anything to "$CATALINA_HOME/lib or >>>> bin" location ,these are read only directories >>>> >>>> http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html >>>> Thanks for your help Vicky >>> >>> Not needed. >>> >>>> >>>> >>>> ________________________________ From: Pid * To: >>>> Tomcat Users List Sent: Saturday, 8 >>>> December 2012 10:34 PM Subject: Re: Tomcat 6.0 CLASSPATH query >>>> >>>> On 8 Dec 2012, at 03:29, "vicky007aggarwal@yahoo.co.in" >>>> wrote: >>>> >>>>> Application is deployed under tomcat webapps directory . It >>>>> tries to refer to application specific properties file from >>>>> tomcat classpath, for that we copied it under tomcat bin >>>>> directory. >>>>> >>>>> My query is that does this is the right way to add properties >>>>> file to tomcat classpath? >>>> >>>> Did you try putting it in tomcat/lib? >>>> >>>> >>>> p >>> >>>> >>>> >>>> >>>>> >>>>> Thanks for ur help, Vicky >>>>> >>>>> >>>>> >>>>> On Dec 8, 2012, at 2:11 AM, Christopher Schultz >>>>> wrote: >>>>> >>>>>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 >>>>>> >>>>>> Vicky, >>>>>> >>>>>> On 12/7/12 11:48 AM, vicky wrote: >>>>>>> I have a requirement in which i need to add couple of >>>>>>> properties files to tomcat CLASSPATH as these are needed for >>>>>>> my application deployed in Tomcat 6.0. >>>>>>> >>>>>>> One strange thing is that, i need to add the all my >>>>>>> properties files to "/bin" directory else >>>>>>> these all wont get added to Tomcat classpath. >>>>>> >>>>>> Where does the code live that attempts to load those >>>>>> properties files? >>>>>> >>>>>> - -chris >>> >>> . . . just my (I hate moving) 2 cents /mde/ >> >> Vicky, >> >> So let me now understand your requirements. >> >> 1. Properties files to be read by web applications >> 2. 10 web applications on one Tomcat instance >> 3. All 10 web applications read identical files >> 4. Property files change frequently >> 5. $CATALINA_HOME and $CATALINA_BASE are read-only >> 6. $CATALINA_BASE/lib and $CATALINA_BASE/bin are read-only >> >> In the future it would be a good idea to list all of your requirements a= nd restrictions at once, rather than having the list extract it by recommen= ding solutions which fail one or more requirements. >> >> The approach (placing resource files on the CLASSPATH) is probably not a= good one given the requirements as you've stated them. >> >> If you're wedded to reading resources from a CLASSPATH, the only reasona= ble way to live with the above requirements is to use files in WEB-INF/clas= ses. Then the application will have to be changed each time you update the = resource files. This all can be scripted so that operations won't have too = big of a burden. >> >> Placing the resources in a JAR somewhere on Tomcat's CLASSPATH poses sev= eral problems. >> >> 1. You cannot modify the directories where Tomcat reads JARs >> 2. A change to the resource will require a Tomcat restart >> >> One of the only ways I can see around this is as follows. >> >> 1. create a setenv.sh in $CATALINA_BASE/bin (or setenv.bat) >> >> I realize you do not have write access to this, but maybe operations can= create that file. >> >> 2. In that setenv.sh, add the following: >> >> CLASSPATH=3D/place/where/your/jar/is.jar >> EXPORT CLASSPATH >> >> 3. Make the /place/where/your/jar/is.jar readable >> >> This JAR file must be readable by the user running Tomcat >> >> 4. In is.jar add all your configuration files >> >> This is a pretty spectacularly bad solution for several reasons. >> >> 1. You're reading a file outside of Tomcat's directory structure >> 2. Eunning under the security manager would be challenging >> 3. Tomcat restart for changing the JAR with the properties files >> >> At this point, I would seriously look at scripting the 10 web applicatio= n updates, or loading the properties files in a database and access them vi= a JNDI. >> >> . . . . just my two cents. >> /mde/ >> >> --------------------------------------------------------------------- >> 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 > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org