Think the easiest way it to do something like:

in configure

String file = 
configuration.getChild(context://WEB-INF/lib/nptl.im.properties).getValue();

Of course, doing  

private static final String PROPERTIES_FILE = "properties-file";

and in configure

configuration.getChild(PROPERTIES_FILE).getValue();



and configure in your component in cocoon.xconf someting like

<your-component>
    <properties-file>context://WEB-INF/lib/nptl.im.properties</properties-file>
</your-component>

is much nicer, because you can configure your location instead of hard-coding 
it in your jar

Regards Ard

> 
> 
> I think you should be looking in the direction of:
> 
>       import java.util.Locale;
>       import java.util.MissingResourceException;
>       import java.util.ResourceBundle;
> 
>       ...
> 
>       Locale locale = Locale.getDefault();
>       try {
>               resources = ResourceBundle.getBundle(
>                               "my.package.MyProperties",
>                               locale);
>       } catch (MissingResourceException e) { 
>               ...
>       }
> 
> you need to put a file MyProperties.properties in a folder 
> my/packages/
> inside any jar that you put into WEB-INF/lib/.
> 
> Kind regards,
> Geert
> 
> > 
>    
>  
> Drs. G.P.H. Josten
> Consultant
>  
>  
> 
> Daidalos BV
> Source of Innovation
> Hoekeindsehof 1-4
> 2665  JZ  Bleiswijk
> Tel.: +31 (0) 10 850 1200
> Fax: +31 (0) 10 850 1199
> www.daidalos.nl
> KvK 27164984
> 
> 
> De informatie - verzonden in of met dit emailbericht - is 
> afkomstig van Daidalos BV en is uitsluitend bestemd voor de 
> geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, 
> verzoeken wij u het te verwijderen. Aan dit bericht kunnen 
> geen rechten worden ontleend.
>  
> 
> > Van: Omar Adobati [mailto:[EMAIL PROTECTED] 
> > Verzonden: donderdag 19 oktober 2006 15:44
> > Aan: [email protected]
> > Onderwerp: Loading a configuration file from a jar
> > 
> > Good Morning,
> > 
> >   I have developed a jar file and I need to load some 
> > configuration parameters from a .properties file placed 
> > outside of the jar itself.
> > 
> > The jar file is under $cocoon/WEB-INF/lib directory and the 
> > .properties file too.
> > Now, the problem is that my own class (that extends the 
> > java.util.Properties class) can't locate the properties file.
> > Here is the code I'm actually using:
> > 
> > public ConfigUtility(){
> >     super();
> >     File configFile = new File("/nptl.im.properties");      
> >     try{
> >       configURL = configFile.toURL();
> >     }catch (Exception ex){
> >            ex.printStackTrace();
> >     }
> >             
> >         //do some other useful stuff
> >   }
> > 
> > I'm running cocoon 2.1.18 with tomcat 5.5.x and JDK 1.5
> > 
> > Thanks for your help :)
> > 
> > --
> > Omar Adobati
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to