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 18:01:23 UTC

RE: How to load properties files inside plugins for maven v 2.0.4

What will be the root context to refer to a properties file in the plugin
jar? Any ideas anyone

Thank you, 

Phani Yadavalli

-----Original Message-----
From: Yadavalli, Phani [mailto:Phani.yadavalli@caremark.com] 
Sent: Tuesday, September 05, 2006 4:45 AM
To: users@maven.apache.org
Subject: 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

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