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
2. Copy old app ctx into new one, using
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();
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]
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.
edit# Ofcourse, copying old ctx file to new one is successfull, both files looks exactly the same.
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;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.