commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Thorburn <>
Subject [CONFIGURATION] Configuration Interpolates when Web Application is run directly under Glassfish, but not when debugging under Eclipse
Date Wed, 02 Sep 2009 05:13:41 GMT
This is something that doesn't make an awful lot of sense to me:

I've got a web application that uses CommonsConfiguration to configure
the logging (first it loads a configuration file as  base, then loads
a new configuration from the database), and for some reason it will
not interpolate the various parameters when I try and debug it under
Eclipse (using the Glassfish WTP plugin). It just doesn't happen.

I'm using Java 1.5, Commons Configuration 1.6, Commons Lang 2.2,
Eclipse 3.5 and Glassfish 2.1.

I know that it works when I run it under Glassfish directly as I can
see the log file being created in the right directory and such, and I
can also see it printing out the parameters with everything
successfully interpolated and expanded.

I'm not sure exactly why it's not doing anything, but there we go.

It doesn't even interpolate System parameters, including ones that
I've set my self.

I can't provide the code which is actually causing the problem, and
I'm not entirely sure how to replicate it. The best I can do is show
code which behaves in a similar fashion:

	 * @param args
	public static void main(String[] args)
		System.setProperty("ProcessID", "pid");
		System.out.println(" [" +
System.getProperty("") + "]");
		Configuration c = new BaseConfiguration();
		c.setProperty("process.default.logfile_directory", "${}");
		c.setProperty("logger.default.filename_prefix", "PREFIX");
		c.setProperty("logger.default.filename_suffix", "log");
		c.setProperty("logger.log4j.rootLogger", "ERROR, APP_ROD, APP_EMAIL");
		c.setProperty("logger.log4j.appender.APP_ROD.DatePattern", "'.'yyyyMMdd");
		CompositeConfiguration cc = new CompositeConfiguration();

	private static void printProperties(Properties props)
		for(Entry<Object, Object> ent : props.entrySet())
			System.out.println("[" + ent.getKey() + "] [" + ent.getValue() + "]");

And the output from the above: [/tmp]

[log4j.rootLogger] [ERROR,APP_ROD,APP_EMAIL]
[log4j.appender.APP_ROD.DatePattern] ['.'yyyyMMdd]
[log4j.appender.APP_ROD] [org.apache.log4j.DailyRollingFileAppender]
[default.filename_prefix] [PREFIX]
[default.filename_suffix] [log]

[process.default.logfile_directory] [${}]
[logger.default.filename_prefix] [PREFIX]
[logger.default.filename_suffix] [log]
[logger.default.filename] [PREFIX${ProcessID}.log]
[logger.log4j.appender.APP_ROD.DatePattern] ['.'yyyyMMdd]
[logger.log4j.appender.APP_ROD] [org.apache.log4j.DailyRollingFileAppender]
[logger.log4j.rootLogger] [ERROR,APP_ROD,APP_EMAIL]

Which seems a little... odd... since it left
process.default.logfile_directory as ${} despite the
property definitely being set.

This differs from my actual problem in that *no* interpolation is
performed when converting to a Properties Object. None at all. Also,
the properties are loaded from an XML file, and then from a
CombinedConfiguration constructed from the XMLFile, System Properties
and a Database Table.

I *know* that it works normally, as a temporary log winds up /tmp.

Having said the above, if I stop Glassfish in Eclipse and then start
it from the command line, I get the same issue (of no interpolation).

There's a variety of issues that could be the problem here. It could
be something funny about the Glassfish plugin. It could be something
to do with how I've got the web project set up - prior to this, it was
built via Ant and deployed directly. It could be something to do with
Eclipse's compiler/classpath/whatever settings.

However, I really don't have a clue where to begin here - has anyone
seen this sort of problem before and been able to find a solution? Any
hints would be most welcome, as I'm not even certain that this is
actually a commons-configuration problem. It's just that
commons-configuration is the visible symptom.

Apologies if the above seems disjointed or unclear.


- Andrew Thorburn

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message