1 Reply Latest reply on Nov 28, 2011 10:55 AM by Aslak Knutsen

    Testing ear files with Arquillian 1.0.0.CR5 and JBoss 7.1

    Robert Panzer Newbie

      Hi,

       

      I am really impressed of the possibilities Arquillian offers for integration testing and how easy it is.

       

      I am just wondering about a few things when testing ear deployments containing a war file:

       

      I have to include the test class into the war module embedded into the ear. Otherwise the class cannot be loaded during runtime, i.e. I have to create my deployment like this:

      @RunWith(Arquillian.class)

      public class EARTest {

          @Deployment

          public static Archive<EnterpriseArchive> getArchive() {

              return ShrinkWrap.create(EnterpriseArchive.class, "Test.ear")

                      .addAsLibraries(new File("E:/work/TestApp/lib").listFiles())

                      .addAsModule(

                          ShrinkWrap.createFromZipFile(WebArchive.class, new File("E:/work/TestApp/modules/MyWebApp.war"))

                              .addClass(EARTest.class)

                          )

                );

          }

      }

       

      If I comment out the .addClass(EARTest.class) I get the following error:

       

          <error message="com.wincornixdorf.test.EARTest from [Module &quot;deployment.Test.ear.MyWebApp.war:main&quot; from Service Module Loader]" type="java.lang.ClassNotFoundException">java.lang.ClassNotFoundException: com.foo.test.EARTest from [Module &quot;deployment.Test.ear.MyWebApp.war:main&quot; from Service Module Loader]

                at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:485)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:421)

                at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:143)

                at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:158)

                at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:126)

                at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:90)

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:151)

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)

                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)

                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)

                at java.lang.Thread.run(Thread.java:662)

       

      Is it ok, that it works like this, or am I doing something wrong?

       

      Kind regards,

      Robert