Details
Description
The wicket.properties file is not being loaded by the Application class due to exclusive use of the thread context classloader in Wicket 1.3.1 when used in an OSGi environment.
From looking at Wicket's Application code, it appears that multiple wicket.properties files can exist, and it will load them all. So, the wicket.properties in wicket.jar should always be loaded as well as any other wicket.properties that are application specific. This will work in a traditional WAR file.
However, in OSGi, each bundle has its own classloader. So, if Wicket is in its own bundle and my web application is in its own bundle, the current implementation of Application will not work. Using only the thread context classloader will not accomodate loading multiple wicket.properties. Multiple classloaders must be checked.
Here's a reference to an mail list thread:
http://www.nabble.com/NPE-in-PropertyResolver.getGetAndSetter%28%29-td11194510.html#a15647641
I've put together and tested a modified Application.java which works in OSGi. Would something like this be acceptable?
public final void initializeComponents()
{
// Load any wicket properties files we can find
try
catch (IOException e)
{ throw new WicketRuntimeException("Unable to load initializers file", e); } // now call any initializers we read
callInitializers();
}
private void loadResources(Enumeration resources, Set loadedFiles) throws IOException
{
if (resources != null)
{
while (resources.hasMoreElements())
{
InputStream in = null;
try
{
final URL url = (URL)resources.nextElement();
if (!loadedFiles.contains(url))
{
log.info("resource url: {} ", url);
final Properties properties = new Properties();
in = url.openStream();
properties.load(in);
load(properties);
loadedFiles.add(url);
}
}
finally
{
if (in != null)
}
}
}
}