Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-4127

CXFServlet should be reinitialized on ContextRefreshedEvent

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.7, 2.5.3
    • 2.5.3, 2.6
    • None
    • None
    • Unknown

    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.

      RefreshingCXFServlet.java
      @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

          Activity

            People

              dkulp Daniel Kulp
              jensborgland Jens Borgland
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: