You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Yadavalli, Phani" <Ph...@caremark.com> on 2006/09/05 11:45:17 UTC
How to load properties files inside plugins
Hi,
I have a file called env.properties embedded within the plug-in jar file.
When I run the files outside the context of a plug-in, they run fine. But
when I try to call the plug-in from another pom.xml I get the following
problem
org.codehaus.classworlds.RealmClassLoader@12940b3
<ma...@12940b3>
file not found hence cannot load
-- listing properties --
-- listing properties --
-- listing properties -
The code for above is
dmpenvironment = loadProperties(is, log, "com/dmp/util/env.properties");
private static Properties loadProperties(InputStream is, Log log, String
fileName)
{
Properties propFile = new Properties();
try
{
is = PropertyLoader.class.getResourceAsStream(fileName);
System.out.println(PropertyLoader.class.getClassLoader().toString());
if (null != is)
propFile.load(is);
else
System.out.println("file not found hence cannot
load");
}
catch (FileNotFoundException fnfe)
{
log.fatal("File not found : ", fnfe);
fnfe.printStackTrace();
}
catch (IOException ioe)
{
log.error("IOException while reading property files",
ioe);
ioe.printStackTrace();
}
}
public static String getEnvironmentProperty(String property)
{
dmpenvironment.list(System.out);
return dmpenvironment.getProperty(property);
}
Thank you,
Phani Yadavalli
ITQA, Caremark Inc,
1000 Lakeside Drive
Bannockburn, IL 60015
847-444-6958
847-444-6000 ext 6958
phani.yadavalli@caremark.com <ma...@caremark.com>