JAR file not finding external properties files
I created some utility classes that read proeprties files (e.g. com.mvp.utils.ExtProperties). In the method where I try to load the properties file I have package com.mvp.utils; class ExtProperties { private static PropertyResourceBundle loadProperties(String propsFile) { PropertyResourceBundle prb = (PropertyResourceBundle) ResourceBundle.getBundle(propsFile); return prb; } } This file is then compiled and placed in a jar file, which is copied to my Tomcat\common\lib directory. Whenver I try to call the ExtProperties class it fails to find the properties file. If I include the properties file in the jar file it finds it with no problem. I assume that this is a class loader problem (which which I am not very familiar). What do I need to do to get the class in the jar file to find the properties files external to it? Do I need to specify the full path to the file? TIA - Mike - Ahhh...imagining that irresistible new car smell? Check outnew cars at Yahoo! Autos.
Re: JAR file not finding external properties files
Your could put the properties file in WEB-INF/classes which is equivalent to storing it in the jar file. Otherwise we'll need to know more about where you are storing your properties file to help. -- David Mike Peremsky wrote: I created some utility classes that read proeprties files (e.g. com.mvp.utils.ExtProperties). In the method where I try to load the properties file I have package com.mvp.utils; class ExtProperties { private static PropertyResourceBundle loadProperties(String propsFile) { PropertyResourceBundle prb = (PropertyResourceBundle) ResourceBundle.getBundle(propsFile); return prb; } } This file is then compiled and placed in a jar file, which is copied to my Tomcat\common\lib directory. Whenver I try to call the ExtProperties class it fails to find the properties file. If I include the properties file in the jar file it finds it with no problem. I assume that this is a class loader problem (which which I am not very familiar). What do I need to do to get the class in the jar file to find the properties files external to it? Do I need to specify the full path to the file? TIA - Mike - Ahhh...imagining that irresistible new car smell? Check outnew cars at Yahoo! Autos. -- David Smith Network Operations Supervisor Department of Entomology Cornell University 2132 Comstock Hall Ithaca, NY 14853 Phone: (607) 255-9571 Fax: (607) 255-0940 - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JAR file not finding external properties files
Oh helps to read all the message:) jars in common/lib can't read files in your webapp. You could use common/classes --David David Smith wrote: Your could put the properties file in WEB-INF/classes which is equivalent to storing it in the jar file. Otherwise we'll need to know more about where you are storing your properties file to help. -- David Mike Peremsky wrote: I created some utility classes that read proeprties files (e.g. com.mvp.utils.ExtProperties). In the method where I try to load the properties file I have package com.mvp.utils; class ExtProperties { private static PropertyResourceBundle loadProperties(String propsFile) { PropertyResourceBundle prb = (PropertyResourceBundle) ResourceBundle.getBundle(propsFile); return prb; } } This file is then compiled and placed in a jar file, which is copied to my Tomcat\common\lib directory. Whenver I try to call the ExtProperties class it fails to find the properties file. If I include the properties file in the jar file it finds it with no problem. I assume that this is a class loader problem (which which I am not very familiar). What do I need to do to get the class in the jar file to find the properties files external to it? Do I need to specify the full path to the file? TIA - Mike - Ahhh...imagining that irresistible new car smell? Check outnew cars at Yahoo! Autos. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JAR file not finding external properties files
The system.properties file is already located in the WEB-INF classes directory. Sorry I am new to this stuff, not sure what other information you need. %CATALINA_HOME%/common/lib/mvp.jar- contains ExtProperties.class %CATALINA_HOME%/webapps/fs/WEB-INF/classes/system.properties %CATALINA_HOME%/webapps/fs/WEB-INF/classes - contains all other classes for fs app David Smith [EMAIL PROTECTED] wrote: Your could put the properties file in WEB-INF/classes which is equivalent to storing it in the jar file. Otherwise we'll need to know more about where you are storing your properties file to help. -- David Mike Peremsky wrote: I created some utility classes that read proeprties files (e.g. com.mvp.utils.ExtProperties). In the method where I try to load the properties file I have package com.mvp.utils; class ExtProperties { private static PropertyResourceBundle loadProperties(String propsFile) { PropertyResourceBundle prb = (PropertyResourceBundle) ResourceBundle.getBundle(propsFile); return prb; } } This file is then compiled and placed in a jar file, which is copied to my Tomcat\common\lib directory. Whenver I try to call the ExtProperties class it fails to find the properties file. If I include the properties file in the jar file it finds it with no problem. I assume that this is a class loader problem (which which I am not very familiar). What do I need to do to get the class in the jar file to find the properties files external to it? Do I need to specify the full path to the file? TIA - Mike - Ahhh...imagining that irresistible new car smell? Check outnew cars at Yahoo! Autos. -- David Smith Network Operations Supervisor Department of Entomology Cornell University 2132 Comstock Hall Ithaca, NY 14853 Phone: (607) 255-9571 Fax: (607) 255-0940 - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Ahhh...imagining that irresistible new car smell? Check outnew cars at Yahoo! Autos.
Re: JAR file not finding external properties files
Hi Mike, On 5/1/07, Mike Peremsky [EMAIL PROTECTED] wrote: What do I need to do to get the class in the jar file to find the properties files external to it? To access a properties file that is external to the JAR file , add the full path of the Properties file's folder to the CLASSPATH. If you add the path of the Properties file to the CLASSPATH, there's no need to place the properties file under /WEB-INF/classes/ folder , it can be located anywhere you want. After setting the CLASSPATH, the properties file can be accessed simply by specifying its name. For example: If the mypropertiesfile.properties is placed under C:/dev/mypropertiesfile.properties set CLASSPATH=%CLASSPATH%;C:/dev/ public class TestPropertiesFile { public static void main(String[] args) { ResourceBundle props = ResourceBundle.getBundle(mypropertiesfile); //String planet = (String) props.getObject(planet); //System.out.println(Planet: + planet); } } TIA - Mike -Regards Rashmi - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JAR file not finding external properties files
Ug. Moving the jar file to %CATALINA_HOME/common/classes now causes my servlet to fail to load, as the base class is in the jar file that was just moved to common/classes. David Smith [EMAIL PROTECTED] wrote: Oh helps to read all the message:) jars in common/lib can't read files in your webapp. You could use common/classes --David David Smith wrote: Your could put the properties file in WEB-INF/classes which is equivalent to storing it in the jar file. Otherwise we'll need to know more about where you are storing your properties file to help. -- David Mike Peremsky wrote: I created some utility classes that read proeprties files (e.g. com.mvp.utils.ExtProperties). In the method where I try to load the properties file I have package com.mvp.utils; class ExtProperties { private static PropertyResourceBundle loadProperties(String propsFile) { PropertyResourceBundle prb = (PropertyResourceBundle) ResourceBundle.getBundle(propsFile); return prb; } } This file is then compiled and placed in a jar file, which is copied to my Tomcat\common\lib directory. Whenver I try to call the ExtProperties class it fails to find the properties file. If I include the properties file in the jar file it finds it with no problem. I assume that this is a class loader problem (which which I am not very familiar). What do I need to do to get the class in the jar file to find the properties files external to it? Do I need to specify the full path to the file? TIA - Mike - Ahhh...imagining that irresistible new car smell? Check outnew cars at Yahoo! Autos. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Ahhh...imagining that irresistible new car smell? Check outnew cars at Yahoo! Autos.
Re: JAR file not finding external properties files
Mike, I see your issue is solved. For the sake of the archives I feel the need to respond to the suggestion of modifying the classpath. Please DO NOT modify the classpath. Best practice is to work with the existing classloader structure and put files in the proper places. Modifying the class path environment variable is just asking for huge problems. You do it and then forget or the next developer/sysadmin in line doesn't know it and all sorts of quirky problems show up. --David Rashmi Rubdi wrote: Hi Mike, On 5/1/07, Mike Peremsky [EMAIL PROTECTED] wrote: What do I need to do to get the class in the jar file to find the properties files external to it? To access a properties file that is external to the JAR file , add the full path of the Properties file's folder to the CLASSPATH. If you add the path of the Properties file to the CLASSPATH, there's no need to place the properties file under /WEB-INF/classes/ folder , it can be located anywhere you want. After setting the CLASSPATH, the properties file can be accessed simply by specifying its name. For example: If the mypropertiesfile.properties is placed under C:/dev/mypropertiesfile.properties set CLASSPATH=%CLASSPATH%;C:/dev/ public class TestPropertiesFile { public static void main(String[] args) { ResourceBundle props = ResourceBundle.getBundle(mypropertiesfile); //String planet = (String) props.getObject(planet); //System.out.println(Planet: + planet); } } TIA - Mike -Regards Rashmi - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JAR file not finding external properties files
Hi David, On 5/1/07, David Smith [EMAIL PROTECTED] wrote: Mike, I see your issue is solved. For the sake of the archives I feel the need to respond to the suggestion of modifying the classpath. Please DO NOT modify the classpath. Best practice is to work with the existing classloader structure and put files in the proper places. Thats a good point, but some people have specific need to keep properties file in a separate location, in this case they have no other choice. But Mike's case is different, he didn't have this restriction, so I agree with you where it can be avoided, it is best to keep the properties file in the classes folder - CLASSPATH issues are one of those that take almost a day or two to track down. Modifying the class path environment variable is just asking for huge problems. You do it and then forget or the next developer/sysadmin in line doesn't know it and all sorts of quirky problems show up. --David -Regards Rashmi - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JAR file not finding external properties files
I agree there may be an exceptionally rare occasion where modifying classpath might be necessary. But such advice should be reserved for expert use only and only if they fully understand the consequences. --David Rashmi Rubdi wrote: Hi David, On 5/1/07, David Smith [EMAIL PROTECTED] wrote: Mike, I see your issue is solved. For the sake of the archives I feel the need to respond to the suggestion of modifying the classpath. Please DO NOT modify the classpath. Best practice is to work with the existing classloader structure and put files in the proper places. Thats a good point, but some people have specific need to keep properties file in a separate location, in this case they have no other choice. But Mike's case is different, he didn't have this restriction, so I agree with you where it can be avoided, it is best to keep the properties file in the classes folder - CLASSPATH issues are one of those that take almost a day or two to track down. Modifying the class path environment variable is just asking for huge problems. You do it and then forget or the next developer/sysadmin in line doesn't know it and all sorts of quirky problems show up. --David -Regards Rashmi - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JAR file not finding external properties files
On 5/1/07, David Smith [EMAIL PROTECTED] wrote: I agree there may be an exceptionally rare occasion where modifying classpath might be necessary. But such advice should be reserved for expert use only and only if they fully understand the consequences. Yup, had I known earlier when Mike made his initial 2 posts that he had the flexibility to put the properties file in the classes folder I would have suggested the classes folder as well. But I was thinking there may be a restriction, also I came across a number of threads at Sun forums that suggested the use of CLASSPATH , so that's where I picked up the solution from. Now that you've made a good point on the best approach, next time this question arises I will know better :-) --David -Regards Rashmi - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]