正在刷新OSGI捆绑包上下文,无法找到Spring NamespaceHandler
我需要在运行时刷新我的应用程序上下文。为此,我将执行以下步骤:正在刷新OSGI捆绑包上下文,无法找到Spring NamespaceHandler,spring,mongodb,osgi,applicationcontext,Spring,Mongodb,Osgi,Applicationcontext,我需要在运行时刷新我的应用程序上下文。为此,我将执行以下步骤: 1.在我的OSGI捆绑包之外创建新的appliction-context.xml 2.使用 InputStream InputStream=new BufferedInputStream(this.getClass().getClassLoader().getResourceAsStream(“/META-INF/spring/application context.xml”) 3.刷新应用程序ctx,这意味着,切换到新的应用程序,
1.在我的OSGI捆绑包之外创建新的appliction-context.xml
2.使用
InputStream InputStream=new BufferedInputStream(this.getClass().getClassLoader().getResourceAsStream(“/META-INF/spring/application context.xml”)代码>
3.刷新应用程序ctx,这意味着,切换到新的应用程序,在捆绑包之外创建
ApplicationContext ctx=newfilesystemxmlapplicationcontext(newCtxPath);
((ConfigurableApplicationContext)ctx).refresh()代码>
但是我越来越
找不到XML架构命名空间的Spring NamespaceHandler
[
在我的application-context.xml中,我不认为这是一个问题,因为在编译过程中,一切正常,当我在运行时尝试刷新ctx时,问题就出现了
编辑#
当然,将旧ctx文件复制到新文件是成功的,两个文件看起来完全相同。我找到了更简单的解决方案
public class CtxRefresher implements ApplicationContextAware {
private ApplicationContext context;
public void refreshApplicationCtx(){
((ConfigurableApplicationContext)context).refresh();
}
@Override
public void setApplicationContext(ApplicationContext ctx) throws BeansException {
context = ctx;
}
}
public class CtxRefresher implements ApplicationContextAware {
private ApplicationContext context;
public void refreshApplicationCtx(){
((ConfigurableApplicationContext)context).refresh();
}
@Override
public void setApplicationContext(ApplicationContext ctx) throws BeansException {
context = ctx;
}
}