Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-2161

Fails to inject qualifier-annotated bean created by producer in embedded jetty

    Details

    • Steps to Reproduce:
      Hide

      git clone https://github.com/grossws/weld-bug-qualifier-inject.git
      cd weld-bug-qualifier-inject
       
      mvn clean package -am exec:exec -pl consumer-jetty-2.3.4
      

      Show
      git clone https: //github .com /grossws/weld-bug-qualifier-inject .git cd weld-bug-qualifier-inject   mvn clean package -am exec : exec -pl consumer-jetty-2.3.4

      Description

      There's multimodule project with producer in dependency jar which produces bean with qualifier annotation. This bean should be injected in main module.

      Weld is initialized using org.jboss.weld.environment.servlet.Listener:

      public class Main {
        public static void main(String[] args) throws Exception {
          ServletContextHandler handler = new ServletContextHandler();
          handler.addEventListener(new Listener());
          handler.addServlet(Consumer.class, "/*");
       
          Server server = new Server(8080);
          server.setHandler(handler);
          server.start();
          server.join();
        }
      }
      

      Servlet code:

      @ApplicationScoped
      public class Consumer extends HttpServlet {
        @Inject
        @BindingAnnotation
        private String s;
       
        public String t() {
          return "test: " + s;
        }
       
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
          resp.setStatus(HttpServletResponse.SC_OK);
          resp.setContentType("text/plain");
          resp.getWriter().write(t());
        }
      }
      

      Other jar contains producer for @BindingAnnotation String:

      @ApplicationScoped
      public class Producer {
        @Produces
        @BindingAnnotation
        public String get() {
          return "test";
        }
      }
      

      Same project works fine with weld-servlet-core 2.3.3.Final. Demo project is published at https://github.com/grossws/weld-bug-qualifier-inject.git, see Steps to Reproduce

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mkouba Martin Kouba
                  Reporter:
                  grossws Konstantin Gribov
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: