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 <its_toas...@yahoo.com>
To: Tomcat Users List <users@tomcat.apache.org> 
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
> <CATALINA_BASE>/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 =
     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 * <p...@pidster.com> To:
> Tomcat Users List <users@tomcat.apache.org> Sent: Saturday, 8
> December 2012 10:34 PM Subject: Re: Tomcat 6.0 CLASSPATH query
>
> On 8 Dec 2012, at 03:29, "vicky007aggar...@yahoo.co.in"
> <vicky007aggar...@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
>> <ch...@christopherschultz.net> 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 "<CATALINA_BASE>/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/

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

Reply via email to