3 Replies Latest reply on Nov 19, 2010 3:44 AM by Aslak Knutsen

    EnterpiseArchive (no war) 404 error

    Luigi Bitonti Newbie

      I get  a 404 error running a test for an EnterpriseArchive (seems similar to what's reported in this FAQ: http://community.jboss.org/wiki/WhydoIgetIllegalStateExceptionKeptongetting404s)

       

      I have named the EnterpriseArchive  test.ear, it includes some ejb jars, some libraries (e.g. logback), but  no war archive.

       

      I am running the test using ant/ivy on jboss 6M4. I can see from the server logs that the ear  deploys correctly, but I get an IllegalStateException with the following  root cause:

       

      Caused by: java.lang.IllegalStateException: Error  launching test at  http://localhost:8080/test/ArquillianServletRunner?outputMode=serializedObject&className=integration.adaptor.importtask.control.CustomerDelegateTest&methodName=testPostConstruct.  Kept on getting 404s.
           at org.jboss.arquillian.protocol.servlet_3.ServletMethodExecutor.execute(ServletMethodExecutor.java:125)
           at org.jboss.arquillian.protocol.servlet_3.ServletMethodExecutor.invoke(ServletMethodExecutor.java:57)

       

       

      The test I am running is really basic (I am trying to get started with arquillian...):

       

       

      @RunWith(Arquillian.class)
      public class CustomerDelegateTest {

       

          @Deployment
           public static Archive<?> createTestArchive() {
               EnterpriseArchive ear = ProjectArchiver.createAdaptorEar();
               return ear;
           }
          
           @EJB
           CustomerDelegate customerDelegate;
          
           @Test
           public void testPostConstruct() {
              assertNotNull(customerDelegate);
           }
          
      }

       

      Any idea on why this could be happening?

       

      Thanks

      Luigi

        • 1. Re: EnterpiseArchive (no war) 404 error
          Luigi Bitonti Newbie

          Hi,

           

          I've just found out that it works if I add to the test.ear archive an (almost) empty test.war archive, using this code:

           

          ....

          WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
                      .addResource(EmptyAsset.INSTANCE, "empty.xhtml");
          adaptorEar.add(war, "/");

          .....

           

          I wonder if I am doing something wrong...

           

          Luigi

          • 2. Re: EnterpiseArchive (no war) 404 error
            Luigi Bitonti Newbie

            ...yes, I was definitely doing something wrong. In the EnterpriseArchive creation method I was introducing in the archive my own application.xml. So I had:

             

            public static EnterpriseArchive createAdaptorEar() {
                    EnterpriseArchive adaptorEar = ShrinkWrap.create(EnterpriseArchive.class, "test.ear")
                        .addModule(new File(LIB_PATH + "logback-classic-0.9.16.jar"))
                        .addModule(new File(LIB_PATH + "logback-core-0.9.16.jar"))
                        .addModule(new File(LIB_PATH + "slf4j-api-1.5.8.jar"))

                        .addModule(new File(LIB_PATH + "my-module.jar"))

                        .addResource("application-test.xml", "application.xml");


                    WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
                        .addResource(EmptyAsset.INSTANCE, "empty.xhtml");
                    adaptorEar.add(war, "/");

             

                    return adaptorEar;

            }

             

            This works, provided that the empty WebArchive is created and listed in the application.xml used for testing (application-test.xml).

             

            However it's fairly useless (at least in my case), since this works as well and it's simpler:

             

            public static EnterpriseArchive createAdaptorEar() {
                     EnterpriseArchive adaptorEar = ShrinkWrap.create(EnterpriseArchive.class, "test.ear")
                         .addModule(new File(LIB_PATH + "logback-classic-0.9.16.jar"))
                         .addModule(new File(LIB_PATH + "logback-core-0.9.16.jar"))
                         .addModule(new File(LIB_PATH + "slf4j-api-1.5.8.jar"))

                        .addModule(new File(LIB_PATH + "my-module.jar"));

             

                    return adaptorEar;

            }

             

            Arquillian takes care of the rest.

             

            On a slightly different note, I've noticed that the EnterpriseArchive has to be named test.ear, otherwise I get an error (injection failure).

             

            Anyway, that's it. It works now. It looks very promising. Sorry if I bothered you.

             

            Luigi

            • 3. Re: EnterpiseArchive (no war) 404 error
              Aslak Knutsen Master

              Just adding the EnterpriseArchive should work and should be the only thing you need. When you add your own WebArchives, the packager in the background is a bit weak at the moment and does not manage to merge the WebArchives.

               

              And yes, in current release you need to call it test.ear to get the guessing game done in the EJB enricher to function. We're working on this.