You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Leon Rosenberg <ro...@googlemail.com> on 2009/04/27 09:47:23 UTC

adding files to classpath

Hello,

we are at the moment migrating to new configuration framework
(http://configureme.dev.java.net) which is working with plain json
files reading them from classpath.
We don't want the configuration files to be part of application
anymore. Instead we want them to be located under $HOME/etc/config/ to
separate application and config.
The problem is now, how to bring those files into the classpath. The
easiest solution I can think of is to link every file under
$HOME/etc/config/ into WEB-INF/classes.
However this doesn't seem very elegant.

Is there any other possibility to add something to the classpath
without screwing up my tomcat installation completely? Something
similar to common/endorsed prior to 6.x? Or is there any possibility
to manipulate classpath via context.xml?

regards
Leon

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


Re: adding files to classpath

Posted by Leon Rosenberg <ro...@googlemail.com>.
On Mon, Apr 27, 2009 at 11:06 PM, Caldarale, Charles R
<Ch...@unisys.com> wrote:
>> From: Leon Rosenberg [mailto:rosenberg.leon@googlemail.com]
>> Subject: Re: adding files to classpath
>>
>> Why should I restart tomcat to change the config in this case?
>
> If you're using ClassLoader.getResourceAsStream() each time you check the config, it should be o.k. without a restart.  However, if you're using some technique that caches the config with the classloader, it won't go away until the classloader does, which won't be until the complete JVM is restarted.

Yes, I'm using getResource, and it works.

> As long as no actual classes are involved, I don't think there's a problem.

Thanks a lot for your help. You have been very helpful as usual!

>
>  - Chuck
>


regards
Leon

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


RE: adding files to classpath

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Leon Rosenberg [mailto:rosenberg.leon@googlemail.com]
> Subject: Re: adding files to classpath
> 
> Why should I restart tomcat to change the config in this case?

If you're using ClassLoader.getResourceAsStream() each time you check the config, it should be o.k. without a restart.  However, if you're using some technique that caches the config with the classloader, it won't go away until the classloader does, which won't be until the complete JVM is restarted.

> so its basically the same as the above, the only difference being 
> that I'm modifying the classpath indirectly.

It's not quite the same, in that there's a separate classloader that handles java.endorsed.dirs, rather than the system classloader.  For these purposes (no classes), the difference is probably moot.  I'd still likely use java.endorsed.dirs, just to keep things separated.

> everything seems to work (including new stuff and old stuff), 
> could I have broken anything I don't see yet by this?

As long as no actual classes are involved, I don't think there's a problem.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


Re: adding files to classpath

Posted by Leon Rosenberg <ro...@googlemail.com>.
On Mon, Apr 27, 2009 at 11:19 AM, Leon Rosenberg
<ro...@googlemail.com> wrote:
> On Mon, Apr 27, 2009 at 10:59 AM, Caldarale, Charles R
>>
>> This is one of those rare instances where you actually could extend the Tomcat classpath with a reference to your config directory, as long as you don't mind sharing >those resources across all your webapps and don't mind restarting Tomcat to change the config.

update, i added to the bottom of setclasspath.sh:

export CLASSPATH=$CLASSPATH:$HOME/etc/configuration

everything seems to work (including new stuff and old stuff), could I
have broken anything I don't see yet by this?

My classpath now is:  ::/Users/lrosenberg/etc/configuration
(yes its a mac)

regards
Leon

P.S. Chuck, I still don't get the "don't mind restarting Tomcat to
change the config" line, what do you mean? I actually see changes in
my configs propagated into the code:-)

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


Re: adding files to classpath

Posted by Leon Rosenberg <ro...@googlemail.com>.
On Mon, Apr 27, 2009 at 10:59 AM, Caldarale, Charles R
<Ch...@unisys.com> wrote:
>> From: Leon Rosenberg [mailto:rosenberg.leon@googlemail.com]
>> Subject: adding files to classpath
>>
>> Is there any other possibility to add something to the classpath
>> without screwing up my tomcat installation completely? Something
>> similar to common/endorsed prior to 6.x?
>
> This is one of those rare instances where you actually could extend the Tomcat classpath with a reference to your config directory, as long as you don't mind sharing >those resources across all your webapps and don't mind restarting Tomcat to change the config.

Why should I restart tomcat to change the config in this case?

>  I wouldn't put any class files in that directory, though.

neither would I :-)

>
> The common/endorsed directory still works, since that's handled by the JVM, not Tomcat.  The value is given to the JVM via the java.endorsed.dirs system property; the >catalina.bat and catalina.sh scripts will set that property based on the contents of the JAVA_ENDORSED_DIRS environment variable.  If you set >JAVA_ENDORSED_DIRS=$HOME/etc/config/ either before starting Tomcat or in setenv.sh, it should work, although again, this will be shared across all webapps.
so its basically the same as the above, the only difference being that
I'm modifying the classpath indirectly.

So I'll probably stick with the first option and set the dir to be
part of the classpath.
Thanks!
Leon

>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
>
>
>
> ---------------------------------------------------------------------
> 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


RE: adding files to classpath

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Leon Rosenberg [mailto:rosenberg.leon@googlemail.com]
> Subject: adding files to classpath
> 
> Is there any other possibility to add something to the classpath
> without screwing up my tomcat installation completely? Something
> similar to common/endorsed prior to 6.x?

This is one of those rare instances where you actually could extend the Tomcat classpath with a reference to your config directory, as long as you don't mind sharing those resources across all your webapps and don't mind restarting Tomcat to change the config.  I wouldn't put any class files in that directory, though.

The common/endorsed directory still works, since that's handled by the JVM, not Tomcat.  The value is given to the JVM via the java.endorsed.dirs system property; the catalina.bat and catalina.sh scripts will set that property based on the contents of the JAVA_ENDORSED_DIRS environment variable.  If you set JAVA_ENDORSED_DIRS=$HOME/etc/config/ either before starting Tomcat or in setenv.sh, it should work, although again, this will be shared across all webapps.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.



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