0
votes

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();

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.

1

1 Answers

1
votes

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;      
    }
}