Re: Tomcat 6.0 CLASSPATH query
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Vicky, On 12/9/12 2:06 PM, vicky wrote: Thanks MARK/CHRIS for all earnest replies, i really owe you guys for your replies. Exporting CLASSPATH wont work ad i believe that Tomcat catalina.sh will ignore it. Anyway i am able to fetch the resource/properties file contents if i place in $CATALINA_BASE/bin directory. That is surprising to me. How does your code load the properties file? I'll bet you aren't even using the ClassLoader (and you *should* be). Actually i read the documentation but no where its been written that by adding resource files to $CATALINA_BASE/bin , tomcat will make them available in its CLASSPATH I don't believe it's true, so it shouldn't be in the documentation. This is weird for me to understand, if you have any thoughts on this behavior then please share else we can close this email thread Nobody should be using CATALINA_BASE/bin for anything: it's for Tomcat's bootstrap classes only. I'm fairly sure that simply dropping a file in there won't do anything at all, unless you have modified Tomcat from its original configuration. If you want something to be globally available, use CATALINA_BASE/lib or configure a shared.loader in catalina.properties. Oh, and write your code properly to load from the class path. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEAREIAAYFAlDF9qwACgkQ9CaO5/Lv0PDwQwCeKVZkWejHUXb7R2uQX92IsSi7 MyQAnjG0iuGjhZcRjDULuDKt94d+cuXr =0hHZ -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 6.0 CLASSPATH query
On 8 Dec 2012, at 20:57, vicky007aggar...@yahoo.co.in vicky007aggar...@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 its_toas...@yahoo.com wrote: See at the end for a truly spectacularly bad potential solution. Note that 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 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 needproperties/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
Re: Tomcat 6.0 CLASSPATH query
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Pid, On 12/8/12 12:04 PM, Pid * wrote: 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? Better yet: did you try putting it in WEB-INF/classes? That's where it *should* be. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEAREIAAYFAlDEwd4ACgkQ9CaO5/Lv0PCWDwCgqOtUlVhyWeZMrWqI99GMVpsj daoAnR6K97x0tjVOm2q1hKAPzcuSFnrP =I4EZ -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 6.0 CLASSPATH query
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Pid, On 12/9/12 4:31 AM, Pid * wrote: On 8 Dec 2012, at 20:57, vicky007aggar...@yahoo.co.in vicky007aggar...@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 Another option is to use a VirtualClassLoader and add some random path (/etc/myawesomewebapps/) to it in all webapps. Honestly, I think there are better ways to load shared configuration than trying to share a .properties file on the disk. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEAREIAAYFAlDEwocACgkQ9CaO5/Lv0PDc7gCfUvtH3K16UuRR/PlRzjfeMYin jbcAoMB15SHyQq/MDRnwr7Ws8CpWoY6h =E9GV -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 6.0 CLASSPATH query
Reply is inline. Please do not top post. I had to read your response and then scroll to the bottom to remember what I wrote. On 12/8/2012 12:57 PM, vicky007aggar...@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 Thanks, Vicky Make a directory under $CATALINA_BASE. Call it Resources. Then add in $CATALINA_BASE/bin/setenv.sh something like the following: CLASSPATH=$CATALINA_BASE/Resouces/your-resource.jar export CLASSPATH Again, I've not done this so who knows if it will work. As Chris and I (and others) have said, these resources really belong in WEB-INF/classes. I have described how you can include those in your build environment. I understand that you have 10 web applications and the configuration files change frequently. At that point, if you don't want to continuously bounce your web applications (or Tomcat), I would look at an alternative way for reading resources. I suggested a database and JNDI. . . . . just my two cents /mde/ On Dec 9, 2012, at 2:09 AM, Mark Eggers its_toas...@yahoo.com wrote: See at the end for a truly spectacularly bad potential solution. Note that 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 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 needproperties/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
Re: Tomcat 6.0 CLASSPATH query
On 12/9/2012 8:55 AM, Christopher Schultz wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Pid, On 12/9/12 4:31 AM, Pid * wrote: On 8 Dec 2012, at 20:57, vicky007aggar...@yahoo.co.in vicky007aggar...@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 Another option is to use a VirtualClassLoader and add some random path (/etc/myawesomewebapps/) to it in all webapps. That's only available in Tomcat 7, yes? Honestly, I think there are better ways to load shared configuration than trying to share a .properties file on the disk. +1 - -chris /mde/ - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 6.0 CLASSPATH query
Thanks MARK/CHRIS for all earnest replies, i really owe you guys for your replies. Exporting CLASSPATH wont work ad i believe that Tomcat catalina.sh will ignore it. Anyway i am able to fetch the resource/properties file contents if i place in $CATALINA_BASE/bin directory. Actually i read the documentation but no where its been written that by adding resource files to $CATALINA_BASE/bin , tomcat will make them available in its CLASSPATH This is weird for me to understand, if you have any thoughts on this behavior then please share else we can close this email thread Thanks, VIcky From: Mark Eggers its_toas...@yahoo.com To: Tomcat Users List users@tomcat.apache.org Sent: Sunday, 9 December 2012 10:43 PM Subject: Re: Tomcat 6.0 CLASSPATH query Reply is inline. Please do not top post. I had to read your response and then scroll to the bottom to remember what I wrote. On 12/8/2012 12:57 PM, vicky007aggar...@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 Thanks, Vicky Make a directory under $CATALINA_BASE. Call it Resources. Then add in $CATALINA_BASE/bin/setenv.sh something like the following: CLASSPATH=$CATALINA_BASE/Resouces/your-resource.jar export CLASSPATH Again, I've not done this so who knows if it will work. As Chris and I (and others) have said, these resources really belong in WEB-INF/classes. I have described how you can include those in your build environment. I understand that you have 10 web applications and the configuration files change frequently. At that point, if you don't want to continuously bounce your web applications (or Tomcat), I would look at an alternative way for reading resources. I suggested a database and JNDI. . . . . just my two cents /mde/ On Dec 9, 2012, at 2:09 AM, Mark Eggers its_toas...@yahoo.com wrote: See at the end for a truly spectacularly bad potential solution. Note that 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 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 needproperties/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
RE: Tomcat 6.0 CLASSPATH query
From: Mark Eggers [mailto:its_toas...@yahoo.com] Subject: Re: Tomcat 6.0 CLASSPATH query Another option is to use a VirtualClassLoader and add some random path (/etc/myawesomewebapps/) to it in all webapps. That's only available in Tomcat 7, yes? Presumably, Chris was referring to VirtualWebappLoader, which has been available in Tomcat for ages. However, it wasn't properly documented until Tomcat 7. - 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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 6.0 CLASSPATH query
On 12/9/2012 12:26 PM, Caldarale, Charles R wrote: From: Mark Eggers [mailto:its_toas...@yahoo.com] Subject: Re: Tomcat 6.0 CLASSPATH query Another option is to use a VirtualClassLoader and add some random path (/etc/myawesomewebapps/) to it in all webapps. That's only available in Tomcat 7, yes? Presumably, Chris was referring to VirtualWebappLoader, which has been available in Tomcat for ages. However, it wasn't properly documented until Tomcat 7. - Chuck I found the docs for Tomcat 7, and didn't see them for Tomcat 6. I should have trawled through the source (still getting settled after the move). I suppose I could look at the source, pattern the docs off of those from Tomcat 7, and submit a patch. . . . . just my two cents /mde/ - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 6.0 CLASSPATH query
On 9 Dec 2012, at 16:58, Christopher Schultz ch...@christopherschultz.net wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Pid, On 12/9/12 4:31 AM, Pid * wrote: On 8 Dec 2012, at 20:57, vicky007aggar...@yahoo.co.in vicky007aggar...@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 Another option is to use a VirtualClassLoader and add some random path (/etc/myawesomewebapps/) to it in all webapps. Honestly, I think there are better ways to load shared configuration than trying to share a .properties file on the disk. If the OP is able to edit files in CATALINA_BASE/lib, then editing catalina.properties and appending a fixed path to common.loader in each instance would also work. p - -chris -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEAREIAAYFAlDEwocACgkQ9CaO5/Lv0PDc7gCfUvtH3K16UuRR/PlRzjfeMYin jbcAoMB15SHyQq/MDRnwr7Ws8CpWoY6h =E9GV -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
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 -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEAREIAAYFAlDCVJcACgkQ9CaO5/Lv0PBTogCgoXLXbB5jx///m6qC+ZxO0f20 xO8An2SZPU8E0LuiPpQRCZPVw8v/T66L =Jmvq -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 6.0 CLASSPATH query
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 needproperties/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 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 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 -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org/ Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEAREIAAYFAlDCVJcACgkQ9CaO5/Lv0PBTogCgoXLXbB5jx///m6qC+ZxO0f20 xO8An2SZPU8E0LuiPpQRCZPVw8v/T66L =Jmvq -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
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 needproperties/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
Re: Tomcat 6.0 CLASSPATH query
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 needproperties/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
Re: Tomcat 6.0 CLASSPATH query
See at the end for a truly spectacularly bad potential solution. Note that 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 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 needproperties/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/ 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
Re: Tomcat 6.0 CLASSPATH query
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 Thanks, Vicky On Dec 9, 2012, at 2:09 AM, Mark Eggers its_toas...@yahoo.com wrote: See at the end for a truly spectacularly bad potential solution. Note that 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 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 needproperties/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
Re: Tomcat 6.0 CLASSPATH query
2012/12/7 vicky vicky007aggar...@yahoo.co.in: Hi Guys, 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. I just want to confirm that is it by design that if i want to add any properties file to Tomcat CLASSPATH then adding files to CATALINA_BASE/bin directory is the solution we have or something else we can also do ??? Please suggest Why cant we add files to CATALINA_BASE/conf directory so that it get added to tomcat CLASSPATH 1. Have you studied the docs? There is a chapter on class loaders and class paths. 2. Blindly adding the conf directory to the classpath will break logging. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 6.0 CLASSPATH query
-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 -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEAREIAAYFAlDCVJcACgkQ9CaO5/Lv0PBTogCgoXLXbB5jx///m6qC+ZxO0f20 xO8An2SZPU8E0LuiPpQRCZPVw8v/T66L =Jmvq -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 6.0 CLASSPATH query
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? 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 -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEAREIAAYFAlDCVJcACgkQ9CaO5/Lv0PBTogCgoXLXbB5jx///m6qC+ZxO0f20 xO8An2SZPU8E0LuiPpQRCZPVw8v/T66L =Jmvq -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org