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

Adding a listener for Container events is not working on Jetty 9

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 3.6.2
    • 3.6.3
    • None
    • None
    • Spring Boot 2.7
      Camel 3.21.1
      CXF 3.6.2

    • Unknown

    Description

      Adding a listener for Container events is not working on Jetty 9

      For example. 

      Add listener using JettyHTTPServerEngine

      @Bean
      public JettyHTTPServerEngineFactory jettyHTTPServerEngineFactory() {
      
          JettyHTTPServerEngineFactory engineFactory = new JettyHTTPServerEngineFactory();
      
          JettyHTTPServerEngine engine = new JettyHTTPServerEngine(
                  new Container.Listener() {
                      @Override
                      public void beanAdded(Container parent, Object child) {
                          //
                      }
      
                      @Override
                      public void beanRemoved(Container parent, Object child) {
                          //
                      }
                  },
                  "localhost",
                  8080);
      
          engineFactory.setEnginesList(Collections.singletonList(engine));
      
          return engineFactory;
      }

      The JettyHTTPServerEngine can't add this listener after the start of the server 
      because Server class does not implement addEventListener method directly, this method comes from the parent class.
      Therefore 
      ReflectionUtil.getDeclaredMethods(container.getClass()) does not return the method addEventListener because this call does not consider methods from parent classes.
       
      The issue was caused by this commit https://github.com/apache/cxf/commit/2ff109358027653d1afd6f252cf6f25048cafbb9

       

      Attachments

        Issue Links

          Activity

            People

              reta Andriy Redko
              ruslan.hryn25 Ruslan Hryn
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: