3 Replies Latest reply on Mar 15, 2013 8:49 AM by salik

    CDI @Alternative problem with Arquillian

    armorer

      Hello!

       

      I've faced with next problem: trying to use CDI @Alternative with Arquillian Testing like shown in http://docs.jboss.org/weld/reference/latest/en-US/html/specialization.html

      If I inject alternatives directly to the Test - deployment error

      If I inject alternatives to some bean first and the to the Test - all works fine

       

      Test application is attached to the post.

      Just uncomment injection in AppTest and run test

       

      p.s.: the same error as for Bean alternatives and as for Stereotype alternatives.

       

      Is this my slip or arquillian bug? Thanks for replies.

        • 1. Re: CDI @Alternative problem with Arquillian
          aslak

          Hmm.. wondering if you're running into a variety of this bug: http://java.net/jira/browse/GLASSFISH-16279

           

          The reported bug is a problem related to activating Alternatives when alt-beans.jar is packaged in WEB-INF/lib.. in your case they are not activated when in EAR/ear-module.jar

           

          Arquillian will create a test.war module with a empty beans.xml in the background and add it to your EAR. The injection into the TestClass happens from this WAR, and in your case, Glassfish seems to be using the WAR's bean manager and not the EJB's bean manager.

           

          if that make sense based on what you are seeing, you can report it on the glassfish issue tracker..

          • 2. Re: CDI @Alternative problem with Arquillian
            christopherp

            Works if you deply as a .war:

             

               protected static Archive<?> createWarArchive() {

                  return ShrinkWrap.create(WebArchive.class, "test.war")

                          .addPackages(true, WithInjectBean.class.getPackage())

                          .addAsWebInfResource("META-INF/beans.xml", ArchivePaths.create("beans.xml"));

               }

            1 of 1 people found this helpful
            • 3. Re: CDI @Alternative problem with Arquillian
              salik

              Doesnt work!