简体   繁体   English

刷新OSGI Bundle上下文,无法找到Spring NamespaceHandler

[英]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.

相关问题 Maven 和 Spring = 无法创建应用程序上下文:无法找到 Spring NamespaceHandler - Maven and Spring = Unable to create application context: Unable to locate Spring NamespaceHandler Spring 3.0 - 无法找到XML模式名称空间上下文的Spring NamespaceHandler - Spring 3.0 — Unable to locate Spring NamespaceHandler for XML schema namespace context 无法找到命名空间的NamespaceHandler('context') - Unable to locate NamespaceHandler for namespace ('context') 无法找到XML架构名称空间springframework上下文的Spring NamespaceHandler - Unable to locate Spring NamespaceHandler for XML schema namespace springframework context 无法找到XML模式名称空间Application-Context的Spring NamespaceHandler - Unable to locate Spring NamespaceHandler for XML schema namespace Application-Context 无法找到 xml 架构命名空间上下文的 spring 命名空间处理程序 - unable to locate spring namespacehandler for xml schema namespace context “无法找到 Spring NamespaceHandler”错误 - "unable to locate Spring NamespaceHandler" error 无法找到Spring NamespaceHandler推土机 - Unable to locate Spring NamespaceHandler Dozer 无法找到Spring NamespaceHandler util - Unable to locate Spring NamespaceHandler util 无法找到Spring NamespaceHandler错误 - unable to locate Spring NamespaceHandler error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM