I have a stateless session bean that creates a RuntimeFactory
and Application
object. Both classes are part of the Social Business Toolkit. Application
is used to read the properties and managed-beans files, but this didn't happen because the RuntimeFactory
was unable to get the Application
object.
AbstractRuntimeFactory
has a Map
with Application
objects:
private Map<ClassLoader,AbstractApplication> applications = new HashMap<ClassLoader, AbstractApplication>();
ClassLoader
is set using this method:
protected ClassLoader getContextClassLoader() {
return Thread.currentThread().getContextClassLoader();
}
The Application
object is retrieved with this method:
public Application getApplicationUnchecked() {
ClassLoader cl = getContextClassLoader();
return applications.get(cl);
}
During debugging I noticed the Thread id stays the same, but there are two different instances of ClassLoader
. How does this happen? There's only one session bean, RuntimeFactory and Application. Shouldn't getContextClassLoader() always give me the same object back?
As I work around I now use:
ClassLoader cl = this.getClass().getClassLoader();
Where this
is the RuntimeFactory
, but I'm not sure if this is a good solution.. it feels more like a workaround to the actual problem.
ps: I'm using WebSphere Portal as application server.