JBoss Web
  1. JBoss Web
  2. JBWEB-224

No injection in AsyncListener in AS 7.1

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved (View Workflow)
    • Priority: Major Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Security Level: Public (Everyone can see)
    • Similar Issues:
      Show 1 results 

      Description

      Using JBoss AS 7.1CRb I have defined the following Servlet AsyncListener:

      @ManagedBean
      public class AsyncServletListener implements AsyncListener {
          
          @Inject
          private AsyncBean asyncBean; 
          
          @Override
          public void onStartAsync(AsyncEvent event) throws IOException {
              System.out.println("onStartAsync");
          }
          
          @Override
          public void onComplete(AsyncEvent event) throws IOException {
              System.out.println("onComplete");
          }
       
          @Override
          public void onError(AsyncEvent event) throws IOException {
              System.out.println("onError");
          }
       
          @Override
          public void onTimeout(AsyncEvent event) throws IOException {
              System.out.println("onTimeout");
          }
      }
      

      I registered this listener on an AsyncContext as follows:

      AsyncContext asyncContext = request.startAsync();
      asyncContext.addListener(asyncContext.createListener(AsyncServletListener.class));
      

      The listener is called correctly, but there's no injection happening. Everything is inside a single war and the mandatory empty beans.xml has been created. JBoss AS is indeed starting up CDI ("Starting weld service" appears in the logs).

      If I run the same code in GlassFish, injection does happen.

        Activity

        Hide
        Remy Maucherat
        added a comment -

        Ok, dynamic beans like this one needed to be added to the component class list.

        Show
        Remy Maucherat
        added a comment - Ok, dynamic beans like this one needed to be added to the component class list.

          People

          • Assignee:
            Remy Maucherat
            Reporter:
            arjan tijms
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: