[英]Refreshing OSGI Bundle context, Unable to locate Spring NamespaceHandler
I need to refresh my application context during runtime. 我需要在运行时刷新我的应用程序上下文。 In order to do that, I'm executing following steps: 为此,我正在执行以下步骤:
1. Create new appliction-context.xml outside my OSGI bundle 1.在我的OSGI包之外创建新的appliction-context.xml
2. Copy old app ctx into new one, using 2.使用将旧应用ctx复制到新应用中
InputStream inputStream = new BufferedInputStream(this.getClass().getClassLoader().getResourceAsStream("/META-INF/spring/application-context.xml"));
3. Refreshing app ctx, which means, switching to new one, created outside bundle ApplicationContext ctx = new FileSystemXmlApplicationContext(newCtxPath); ((ConfigurableApplicationContext)ctx).refresh();
3.刷新应用程序ctx,这意味着切换到新的应用程序ctx,它是在捆绑包ApplicationContext ctx = new FileSystemXmlApplicationContext(newCtxPath); ((ConfigurableApplicationContext)ctx).refresh();
之外创建的ApplicationContext ctx = new FileSystemXmlApplicationContext(newCtxPath); ((ConfigurableApplicationContext)ctx).refresh();
ApplicationContext ctx = new FileSystemXmlApplicationContext(newCtxPath); ((ConfigurableApplicationContext)ctx).refresh();
But I'm getting 但是我越来越
Unable to locate Spring NamespaceHandler for XML schema namespace [ http://www.springframework.org/schema/data/mongo] 无法找到用于XML模式名称空间的Spring NamespaceHandler [ http://www.springframework.org/schema/data/mongo]
http://www.springframework.org/schema/data/mongo
is inside my application-context.xml, I don't think thats an issue because during compile, everything works fine, problem occurs when I try to refresh ctx during runtime. 在我的application-context.xml内部,我认为这不是问题,因为在编译过程中,一切正常,当我尝试在运行时刷新ctx时出现问题。
edit# Ofcourse, copying old ctx file to new one is successfull, both files looks exactly the same. 当然,将旧的ctx文件复制到新的文件是成功的,两个文件看起来完全一样。
I found much simpler solution. 我找到了更简单的解决方案。
public class CtxRefresher implements ApplicationContextAware {
private ApplicationContext context;
public void refreshApplicationCtx(){
((ConfigurableApplicationContext)context).refresh();
}
@Override
public void setApplicationContext(ApplicationContext ctx) throws BeansException {
context = ctx;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.