7 Replies Latest reply on Sep 1, 2015 7:49 AM by mayerw01

    Wildfly9 @Observes Consumer<Object> bug?

    arkadyn

      When I run localhost:8080/app/res/observer browser is 'working' waiting for answer but it never comes.

      It is like fired object is not caught by Observes.

      It is working on Glassfish without any problems.

      So, is it WF bug or I missed something?

       

      @Path("observer")

      public class Test {

       

          @Inject

          Event<Consumer<Object>> event;

       

          @GET

          public void getResult(@Suspended AsyncResponse response) {

              Consumer<Object> consumer = response::resume;

              event.fire(consumer);

              Logger.getLogger(this.getClass().getName()).info("getResult() called");

          }

      }

       

      @Singleton

      public class Helper implements Serializable {

       

          @Resource

          ManagedExecutorService mes;

       

          public void observer(@Observes Consumer<Object> consumer) {

              Logger.getLogger(this.getClass().getName()).info("observer() called " + consumer.toString());

              Supplier<String> supplier = this::info;

              try {

                  CompletableFuture.supplyAsync(supplier, mes).thenAccept(consumer).get();

              } catch (InterruptedException | ExecutionException e) {

                  Logger.getLogger(this.getClass().getName()).info(e.getMessage());

              }

          }

       

          public String info() {

              return "Just testing";

          }

      }

       

       

      @ApplicationPath("res")

      public class JAXRSConfig extends Application {

       

          public JAXRSConfig() {

          }

      }

        • 1. Re: Wildfly9 @Observes Consumer<Object> bug?
          tremes

          Hi ark,

          What type of deployment archive do you have? is it war? It looks little bit suspicious at least from CDI perspective. Do you have beans.xml file in your deployment and if so what's the content? Can you provide some reproducing app by any chance?

          • 2. Re: Wildfly9 @Observes Consumer<Object> bug?
            arkadyn

            Yes, this is war archive, and yes I have beans.xml with bean-discovery-mode="all". I've tried it as EJB or CDI bean.

            You can easliy reproduce this by creating a project, these 3 classes, and calling localhost:8080/app/res/observer in web browser.

            It works on Glassfish, so from my perspective it is some problem with WF.

            But i might be wrong ;)

            • 3. Re: Wildfly9 @Observes Consumer<Object> bug?
              mayerw01

              Hmm, the 'waiting problem' comes up on my WildFly as well

               

              But when I try to run this project on GlassFish Server Open Source Edition 4.1 I get an exception instead:

              MultiException stack 1 of 1

              org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=Event<Consumer<Object>>,parent=Test,qualifiers={},position=-1,optional=false,self=false,unqualified=null,829499833)

               

              Did I miss something?

              • 4. Re: Wildfly9 @Observes Consumer<Object> bug?
                arkadyn

                I've just installed fresh copy of Glassfish 4.1 and it works fine for me.

                My war package contains those 3 classes, each in separate file, an empty web.xml file

                and beans.xml with  bean-discovery-mode="all". Thats all.

                All is running on java version 1.8.0_60.

                • 5. Re: Wildfly9 @Observes Consumer<Object> bug?
                  mayerw01

                  Sorry, I've forgotten to change the bean-discovery-mode. It is working in Glassfish now.

                  Strange, seems that there is some issue with starting the process asynchronous

                  • 6. Re: Wildfly9 @Observes Consumer<Object> bug?
                    tremes

                    I don't have much experience with JAX-RS but I am seeing the "waiting" problem on GlassFIsh as well (running on glassfish-4.1-b15-08_30_2015 and jdk 1.8.0_60).

                    • 7. Re: Wildfly9 @Observes Consumer<Object> bug?
                      mayerw01

                      Tomas, as far as I understand build 15 is not officially released (Nightly Build). This might be the cause of your problem.

                      The latest release should be build 13.