Description
I have a web application that uses Spring and CXF and is deployed on Tomcat. The application is initialized using the org.springframework.web.context.ContextLoaderListener.
With the fix for CXF-4094 I am now able to refresh the Spring context (like described below) without any exceptions but since the CXFServlet isn't created by Spring and doesn't listen for ContextRefreshedEvent, the Bus and the DestinationRegistry doesn't get reinitialized.
I refresh the Spring context like this:
((ConfigurableApplicationContext)applicationContext).refresh();
I think the CXFServlet should implement ApplicationListener<ContextRefreshedEvent> and register itself as an application listener on the Spring context and reinitialize itself in the onApplicationEvent method.
As an experiment I created a subclass to CXFServlet with the implementation of onApplicationEvent below (which seems to work). The real implementation could perhaps do a bit less work.
@Override public void onApplicationEvent(ContextRefreshedEvent event) { destroy(); setBus(null); try { super.init(m_sc); } catch (ServletException e) { throw new RuntimeException("Unable to reinitialize the CXFServlet", e); } }
Attachments
Issue Links
- is related to
-
CXF-4094 Refreshing Spring application context leads to NPE
- Closed