4 Replies Latest reply on Dec 10, 2013 5:04 PM by Ian Hands

    Seam 2.3.1 on EAP 6.1.1 Arquillian testing issues

    Ian Hands Newbie

      I am having some issues using Arquillian to run a simple Seam 2 ComponentTest.

      Whenever I include jboss-seam in my deployment (or if I just Maven.resolver().loadPomFromFile("pom.xml").importCompileAndRuntimeDependencies()) I get the following error:

      java.lang.RuntimeException: java.lang.RuntimeException: Error handling file /content/portal-test.war/WEB-INF/lib/jboss-seam-2.3.1.Final.jar
        at org.jboss.seam.mock.JUnitSeamTest.begin(JUnitSeamTest.java:38)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
        at org.jboss.arquillian.junit.Arquillian$StatementLifecycleExecutor.invoke(Arquillian.java:351)
        at org.jboss.arquillian.container.test.impl.execution.BeforeLifecycleEventExecuter.on(BeforeLifecycleEventExecuter.java:35)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
        at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
        at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
        at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
        at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.before(EventTestRunnerAdaptor.java:95)
        at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:222)
        at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
        at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
        at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:240)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
        at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185)
        at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
        at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
        at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
        at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65)
        at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:160)
        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:295)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)
        at java.lang.Thread.run(Thread.java:679)
      Caused by: java.lang.RuntimeException: Error handling file /content/portal-test.war/WEB-INF/lib/jboss-seam-2.3.1.Final.jar
        at org.jboss.seam.deployment.URLScanner.handleArchiveByFile(URLScanner.java:134)
        at org.jboss.seam.deployment.URLScanner.handle(URLScanner.java:107)
        at org.jboss.seam.deployment.URLScanner.scanResources(URLScanner.java:90)
        at org.jboss.seam.deployment.StandardDeploymentStrategy.scan(StandardDeploymentStrategy.java:119)
        at org.jboss.seam.init.Initialization.create(Initialization.java:131)
        at org.jboss.seam.mock.AbstractSeamTest.startSeam(AbstractSeamTest.java:950)
        at org.jboss.seam.mock.JUnitSeamTest.begin(JUnitSeamTest.java:32)
        ... 80 more
      Caused by: java.util.zip.ZipException: error in opening zip file
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:131)
        at java.util.zip.ZipFile.<init>(ZipFile.java:148)
        at org.jboss.seam.deployment.URLScanner.handleArchiveByFile(URLScanner.java:123)
        ... 86 more
      
      
      

       

       

      If I don't include the jboss-seam jar in my deployable (a shrinkwrap WAR) I get the following error:

      15:10:39,468 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015876: Starting deployment of "portal-test.war" (runtime-name: "portal-test.war")
      15:10:40,482 WARN  [org.jboss.as.ee] (MSC service thread 1-1) JBAS011006: Not installing optional component org.jboss.seam.mock.MockSeamListener due to exception: java.lang.ClassNotFoundException: org.jboss.seam.mock.MockSeamListener from [Module "deployment.portal-test.war:main" from Service Module Loader]
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:196) [jboss-modules.jar:1.2.2.Final-redhat-1]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:444) [jboss-modules.jar:1.2.2.Final-redhat-1]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:432) [jboss-modules.jar:1.2.2.Final-redhat-1]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:399) [jboss-modules.jar:1.2.2.Final-redhat-1]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:374) [jboss-modules.jar:1.2.2.Final-redhat-1]
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:119) [jboss-modules.jar:1.2.2.Final-redhat-1]
        at java.lang.Class.forName0(Native Method) [rt.jar:1.6.0_24]
        at java.lang.Class.forName(Class.java:266) [rt.jar:1.6.0_24]
        at org.jboss.as.server.deployment.reflect.DeploymentClassIndex.classIndex(DeploymentClassIndex.java:54)
        at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:78) [jboss-as-ee-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:120)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146) [rt.jar:1.6.0_24]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.6.0_24]
        at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_24]
      
      

       

      Has anyone else run into this issue when using Seam 2.3 and Arquillian?

       

      For an example, here is the simple test class I am trying to use:

      package com.example.sso;
      
      
      import java.io.File;
      import java.util.ArrayList;
      import java.util.Arrays;
      import java.util.List;
      import junit.framework.Assert;
      import org.jboss.arquillian.container.test.api.Deployment;
      import org.jboss.arquillian.junit.Arquillian;
      import org.jboss.seam.mock.JUnitSeamTest;
      import org.jboss.shrinkwrap.api.Archive;
      import org.jboss.shrinkwrap.api.ShrinkWrap;
      import org.jboss.shrinkwrap.api.spec.WebArchive;
      import org.jboss.shrinkwrap.resolver.api.maven.Maven;
      import org.jboss.shrinkwrap.resolver.api.maven.strategy.RejectDependenciesStrategy;
      import org.junit.Test;
      import org.junit.runner.RunWith;
      import com.example.CookieHelper;
      
      
      @RunWith(Arquillian.class)
      public class SSOHelperTest extends JUnitSeamTest {
      
      
        @Deployment(name = "SSOHelperTest")
        public static Archive<?> createDeployment() {
        final WebArchive war = ShrinkWrap.create(WebArchive.class, "portal-test.war"); // .as(WebArchive.class);
        war.addClasses(SSOHelper.class);
        war.delete("/WEB-INF/web.xml");
        war.addAsWebInfResource("./web.xml");
      
      
        // List for libs
        final List<File> libs = new ArrayList<File>();
      
      
        // Add seam libs
        libs.addAll(Arrays.asList(Maven.resolver().loadPomFromFile("pom.xml").resolve("org.jboss.seam:jboss-seam")
        .using(new RejectDependenciesStrategy(false, "org.testng:testng")).asFile()));
        libs.addAll(Arrays.asList(Maven.resolver().loadPomFromFile("pom.xml").resolve("dom4j:dom4j").withTransitivity().asFile()));
        libs.addAll(Arrays.asList(Maven.resolver().loadPomFromFile("pom.xml").resolve("org.javassist:javassist").withTransitivity().asFile()));
      
      
        // load maven resolver
        libs.addAll(Arrays.asList(Maven.resolver().loadPomFromFile("pom.xml").resolve("org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-maven").withTransitivity().asFile()));
      
      
        war.addAsLibraries(libs.toArray(new File[libs.size()]));
        return war;
        }
      
      
        /**
        * Test that the factory is behaving.
        */
        @Test
        public void testGetCookieHelper() throws Exception {
        new ComponentTest() {
        @Override
        protected void testComponents() throws Exception {
        assert (CookieHelper) getValue("#{cookieHelper}") != null;
        }
        }.run();
        }
      }