我有一个无状态会话bean,它创建一个RuntimeFactory
和Application
对象。这两个课程都是Social Business Toolkit的一部分。 Application
用于读取属性和受管Bean文件,但是这并未发生,因为RuntimeFactory
无法获取Application
对象。Thread.currentThread()。getContextClassLoader()返回多个对象实例
AbstractRuntimeFactory
具有Map
与Application
对象:
private Map<ClassLoader,AbstractApplication> applications = new HashMap<ClassLoader, AbstractApplication>();
ClassLoader
是使用此方法设置:
protected ClassLoader getContextClassLoader() {
return Thread.currentThread().getContextClassLoader();
}
的Application
对象与该方法检索到:
public Application getApplicationUnchecked() {
ClassLoader cl = getContextClassLoader();
return applications.get(cl);
}
都灵g调试我注意到线程ID保持不变,但有两个不同的ClassLoader
实例。这是如何发生的?只有一个会话bean,RuntimeFactory和Application。不应该getContextClassLoader()总是给我同样的对象吗?
正如我解决我现在使用:
ClassLoader cl = this.getClass().getClassLoader();
哪里this
是RuntimeFactory
,但我不知道这是一个很好的解决方案。它给人的感觉更像一个解决方法的实际问题。
ps:我正在使用WebSphere Portal作为应用程序服务器。
是你的类装载家长首先还是家长最后? –
这是PARENT_LAST。 – magnetronnie