12 Replies Latest reply on Feb 6, 2012 10:34 AM by aslak

    Two @OperateOnDeployment annotation in test

    ochaloup

      Hi,

       

      I have test for Jboss AS7 and I have problem with following code.

       

      @RunWith(Arquillian.class)
      public class PostConstructTC {
          private static final Logger log = Logger.getLogger(PostConstructTC.class);
          
          @ArquillianResource
          InitialContext ctx;
      
          @Deployment(managed=true, testable = false, name = "single", order = 0)
          public static Archive<?> deploymentSingleton()  {
              final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "single.jar")
                      .addClasses(CounterSingleton.class, ICounterSingleton.class);
              log.info(jar.toString(true));
              return jar;
          }
      
          @Deployment(managed=true, testable = true, name = "postconstruct", order = 2)
          public static Archive<?> deploy() {
              JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "postconstruct.jar")
                      .addClasses(CountedSessionBean.class);
              jar.addAsManifestResource(new StringAsset("Dependencies: deployment.single.jar \n"), "MANIFEST.MF");    
              log.info(jar.toString(true));
              return jar;
          }
          
          @Deployment(managed=true, testable = true, name = "postconstruct2", order = 1)
          public static Archive<?> deploy2() {
              JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "postconstruct2.jar")
                      .addClasses(CountedSessionBean2.class);
              jar.addAsManifestResource(new StringAsset("Dependencies: deployment.single.jar \n"), "MANIFEST.MF");    
              log.info(jar.toString(true));
              return jar;
          }
          
          @Test
          @OperateOnDeployment("postconstruct")
          public void test() throws NamingException {
              InitialContext ctx = new InitialContext();
              log.error(ctx);
              CountedSessionBean bean = (CountedSessionBean) ctx.lookup("java:global/postconstruct/" + CountedSessionBean.class.getSimpleName());
              bean.doSomething();
          }
          
          @Test
          @OperateOnDeployment("postconstruct2")
          public void test2() throws NamingException {
              CountedSessionBean2 bean = (CountedSessionBean2) ctx.lookup("java:global/postconstruct2/" + CountedSessionBean2.class.getSimpleName());
              bean.doSomething();
          }
      }
      

       

      The problem is that when both of the @Test method are enabled then one of them starts to throw ClassNotFoundException on the CountedSessionBean or CountedSessionBean2 respectively. I'm not sure whether the injection of initial context could be done like that. But I did some experiments with

      public void test(@ArquillianResource @OperatesOnDeployment("postconstruct") InitialContext ctx) {...}
      

      but I wasn't successful.

      When I left only one @Test method active then all worked fine (test() and test2()) but both @Test activated causes falling one of them on CNFE.

        • 1. Re: Two @OperateOnDeployment annotation in test
          ochaloup

          How I found it's probably connected to issue https://issues.jboss.org/browse/ARQ-480.

          • 2. Re: Two @OperateOnDeployment annotation in test
            jaikiran

            That JIRA doesn't look related. What exactly is the exception stacktrace that you are seeing?

            • 3. Re: Two @OperateOnDeployment annotation in test
              ochaloup

              I have got this feeling because of  https://issues.jboss.org/browse/AS7-3315 seems to be similar to this problem. And that jira was rejected for being connected to the ARQ-480.

               

              Stacktrace of exception which I get:

              ERROR [org.jboss.as.test.integration.ejb.stateless.pooling.test.PostConstructTC] (pool-4-thread-1) javax.naming.InitialContext@19c21c6

              ERROR [org.jboss.arquillian.protocol.jmx.JMXTestRunner] (pool-4-thread-1) Failed: org.jboss.as.test.integration.ejb.stateless.pooling.test.PostConstructTC.test: java.lang.NoClassDefFoundError: org/jboss/as/test/integration/ejb/stateless/pooling/test/CountedSessionBean

                  at org.jboss.as.test.integration.ejb.stateless.pooling.test.PostConstructTC.test(PostConstructTC.java:78) [postconstruct2.jar:]

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_23]

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_23]

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23]

                  at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]

                  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) [arquillian-service:]

                  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) [arquillian-service:]

                  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) [arquillian-service:]

                  at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:270) [arquillian-service:]

                  at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60) [arquillian-service:]

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_23]

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_23]

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23]

                  at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]

                  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90) [arquillian-service:]

                  at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) [arquillian-service:]

                  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) [arquillian-service:]

                  at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:134) [arquillian-service:]

                  at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114) [arquillian-service:]

                  at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67) [arquillian-service:]

                  at org.jboss.arquillian.container.test.impl.execution.ContainerTestExecuter.execute(ContainerTestExecuter.java:38) [arquillian-service:]

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_23]

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_23]

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23]

                  at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]

                  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90) [arquillian-service:]

                  at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) [arquillian-service:]

                  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) [arquillian-service:]

                  at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89) [arquillian-service:]

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_23]

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_23]

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23]

                  at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]

                  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90) [arquillian-service:]

                  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) [arquillian-service:]

                  at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75) [arquillian-service:]

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_23]

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_23]

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23]

                  at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]

                  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90) [arquillian-service:]

                  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) [arquillian-service:]

                  at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60) [arquillian-service:]

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_23]

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_23]

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23]

                  at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]

                  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90) [arquillian-service:]

                  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) [arquillian-service:]

                  at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:134) [arquillian-service:]

                  at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111) [arquillian-service:]

                  at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:263) [arquillian-service:]

                  at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:226) [arquillian-service:]

                  at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314) [arquillian-service:]

                  at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46) [arquillian-service:]

                  at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:240) [arquillian-service:]

                  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) [arquillian-service:]

                  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) [arquillian-service:]

                  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) [arquillian-service:]

                  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) [arquillian-service:]

                  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) [arquillian-service:]

                  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) [arquillian-service:]

                  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) [arquillian-service:]

                  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) [arquillian-service:]

                  at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185) [arquillian-service:]

                  at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314) [arquillian-service:]

                  at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46) [arquillian-service:]

                  at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199) [arquillian-service:]

                  at org.junit.runners.ParentRunner.run(ParentRunner.java:300) [arquillian-service:]

                  at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147) [arquillian-service:]

                  at org.junit.runner.JUnitCore.run(JUnitCore.java:157) [arquillian-service:]

                  at org.junit.runner.JUnitCore.run(JUnitCore.java:136) [arquillian-service:]

                  at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65) [arquillian-service:]

                  at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethodInternal(JMXTestRunner.java:128) [arquillian-service:]

                  at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethod(JMXTestRunner.java:107) [arquillian-service:]

                  at org.jboss.as.arquillian.service.ArquillianService$ExtendedJMXTestRunner.runTestMethod(ArquillianService.java:226) [arquillian-service:]

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_23]

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_23]

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23]

                  at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]

                  at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:93) [:1.6.0_23]

                  at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:27) [:1.6.0_23]

                  at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:208) [:1.6.0_23]

                  at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:120) [:1.6.0_23]

                  at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:262) [:1.6.0_23]

                  at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836) [:1.6.0_23]

                  at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761) [:1.6.0_23]

                  at org.jboss.as.jmx.PluggableMBeanServerImpl$TcclMBeanServer.invoke(PluggableMBeanServerImpl.java:489)

                  at org.jboss.as.jmx.PluggableMBeanServerImpl.invoke(PluggableMBeanServerImpl.java:243)

                  at org.jboss.remoting3.jmx.protocol.v1.ServerProxy$InvokeHandler.handle(ServerProxy.java:1034)

                  at org.jboss.remoting3.jmx.protocol.v1.ServerProxy$MessageReciever$1.run(ServerProxy.java:215)

                  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_23]

                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_23]

                  at java.lang.Thread.run(Thread.java:662) [:1.6.0_23]

              Caused by: java.lang.ClassNotFoundException: org.jboss.as.test.integration.ejb.stateless.pooling.test.CountedSessionBean from [Module "deployment.postconstruct2.jar:main" from Service Module Loader]

                  at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.0.CR8]

                  at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.0.CR8]

                  at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.0.CR8]

                  at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423) [jboss-modules.jar:1.1.0.CR8]

                  at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.0.CR8]

                  at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.0.CR8]

                  ... 94 more

              • 4. Re: Two @OperateOnDeployment annotation in test
                aslak

                When executing something that is targeting deployment X your seeing CNFE on classes not found from deployment Y, right ?

                 

                There is a TestClass filtering that is not yet done in Arquillian Core, so if the TestClass is refering to Classes not in the deployment it will 'likely' fail with a CNFE.  This is especially true when you're operating on multiple different deployment with different content. One Test referes to something from X and another Test referes to something from Y. When the first Test is executed the Class is refering to classes in the second Test that is outside of it's current context.

                 

                Multiple in-container deployments currently works best with 'cluster' type deployments, or deployments where you can rely on common interfaces between the two. deployments in the TestClass.

                • 5. Re: Two @OperateOnDeployment annotation in test
                  ochaloup

                  I think that it's not my case.

                  The exception above fails on line 78 where the following code is:

                  CountedSessionBean bean = (CountedSessionBean) ctx.lookup("java:global/postconstruct/" + CountedSessionBean.class.getSimpleName());

                  The method test() is connected to postconstruct deployment and not to postconstruct2 and the CountedSessionBean is placed in postconstruct.jar which is created in the same deployment. But it seems to me that initial context is bind only to one of the deployments. In this case its postconstruct2 and I'm not sure why but it searches the CountedSessionBean class in deployment.postconstruct2.jar.

                   

                  I hope that I haven't overlooked something but I try to use bean created in deployment X in test conected to the same deployment. I do not use class created in deployment X in test working on deployment Y.

                  • 6. Re: Two @OperateOnDeployment annotation in test
                    aslak

                    aa.. right..

                     

                    The problem is most likly in the AS7 Arquillian Service, which searches deployments for TestClasses so it knows which context to execute it within when the JMX request comes in... The second discovery of the TestClass in deployment 2 probably overrides the one found in deployment 1. The JMX protocol has no extract 'deployment' information added to it besides the TestClass, as appose to the Servlet Protocl which has the War ContextRoot as a base for the call.

                     

                    It's not the initialcontext that is wrong, it's in which module the Test is executed..

                     

                    Caused by: java.lang.ClassNotFoundException: org.jboss.as.test.integration.ejb.stateless.pooling.test.CountedSessionBean from [Module "deployment.postconstruct2.jar:main" from Service Module Loader]

                     

                    You can try to swap the deployments to use the Servlet protocol instead, might help. (unless you run into the issue i first assumed it was)

                     

                    Make sure you have org.jboss.arquillian.protocol:arquillian-protocol-servlet artifact on classpath and add @OverProtocol("Servlet 3.0") to the postconstruct and postconstruct2 deployments.  e.g. @Deployment(...) @OverProtocol("Servlet 3.0")

                    • 7. Re: Two @OperateOnDeployment annotation in test
                      ochaloup

                      Hi,

                       

                      thank you. I tried it how you recommended but I did not have success.

                       

                      I put the annotation in way:

                      @Deployment(managed=true, testable = true, name = "postconstruct", order = 2)

                      @OverProtocol("Servlet 3.0")

                      public static Archive<?> deploy() {

                      ...

                      But I get exceptions. On client/test side it's these ones:

                      test(org.jboss.as.test.integration.ejb.stateless.pooling.test.PostConstructTC)  Time elapsed: 0.261 sec  <<< ERROR!

                      javax.naming.NameNotFoundException: postconstruct/CountedSessionBean -- service jboss.naming.context.java.global.postconstruct.CountedSessionBean

                          at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)

                          at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:177)

                          at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:123)

                          at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:213)

                          at javax.naming.InitialContext.lookup(InitialContext.java:392)

                          at org.jboss.as.test.integration.ejb.stateless.pooling.test.PostConstructTC.test(PostConstructTC.java:81)

                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                          at java.lang.reflect.Method.invoke(Method.java:597)

                          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.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:270)

                          at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60)

                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                          at java.lang.reflect.Method.invoke(Method.java:597)

                          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                          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.core.impl.ManagerImpl.fire(ManagerImpl.java:134)

                          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)

                          at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

                          at org.jboss.arquillian.container.test.impl.execution.ContainerTestExecuter.execute(ContainerTestExecuter.java:38)

                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                          at java.lang.reflect.Method.invoke(Method.java:597)

                          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                          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:39)

                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                          at java.lang.reflect.Method.invoke(Method.java:597)

                          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                          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:39)

                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                          at java.lang.reflect.Method.invoke(Method.java:597)

                          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                          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:39)

                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                          at java.lang.reflect.Method.invoke(Method.java:597)

                          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:134)

                          at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111)

                          at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:263)

                          at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:226)

                          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: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:154)

                          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.Http11AprProcessor.process(Http11AprProcessor.java:897)

                          at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:626)

                          at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2033)

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

                      test2(org.jboss.as.test.integration.ejb.stateless.pooling.test.PostConstructTC)  Time elapsed: 0.177 sec  <<< ERROR!

                      java.lang.Exception: No runnable methods

                          at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:166)

                          at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:102)

                          at org.junit.runners.ParentRunner.validate(ParentRunner.java:344)

                          at org.junit.runners.ParentRunner.<init>(ParentRunner.java:74)

                          at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:55)

                          at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:13)

                          at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)

                          at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)

                          at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)

                          at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)

                          at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:33)

                          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.jmx.JMXTestRunner.runTestMethodInternal(JMXTestRunner.java:128)

                          at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethod(JMXTestRunner.java:107)

                          at org.jboss.as.arquillian.service.ArquillianService$ExtendedJMXTestRunner.runTestMethod(ArquillianService.java:226)

                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                          at java.lang.reflect.Method.invoke(Method.java:597)

                          at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:93)

                          at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:27)

                          at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:208)

                          at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:120)

                          at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:262)

                          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)

                          at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)

                          at org.jboss.as.jmx.PluggableMBeanServerImpl$TcclMBeanServer.invoke(PluggableMBeanServerImpl.java:489)

                          at org.jboss.as.jmx.PluggableMBeanServerImpl.invoke(PluggableMBeanServerImpl.java:243)

                          at org.jboss.remoting3.jmx.protocol.v1.ServerProxy$InvokeHandler.handle(ServerProxy.java:1034)

                          at org.jboss.remoting3.jmx.protocol.v1.ServerProxy$MessageReciever$1.run(ServerProxy.java:215)

                          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

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

                       

                      and the one on server side

                      INFO  [org.jboss.as.arquillian] (MSC service thread 1-2) Arquillian deployment detected: ArquillianConfig[service=jboss.arquillian.config."test.war",unit=test.war,tests=[org.jboss.as.test.integration.ejb.stateless.pooling.test.PostConstructTC]]

                      INFO  [org.jboss.web] (MSC service thread 1-6) JBAS018210: Registering web context: /test

                      INFO  [org.jboss.as.server] (management-handler-threads - 1) JBAS018559: Deployed "test.war"

                      INFO  [org.jboss.arquillian.testenricher.cdi.container.BeanManagerProducer] (http-localhost.localdomain-127.0.0.1-8080-2) BeanManager not found.

                      ERROR [org.jboss.arquillian.protocol.jmx.JMXTestRunner] (pool-4-thread-1) Failed: org.jboss.as.test.integration.ejb.stateless.pooling.test.PostConstructTC.test2: java.lang.Exception: No runnable methods

                          at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:166) [arquillian-junit.jar:]

                          at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:102) [arquillian-junit.jar:]

                          at org.junit.runners.ParentRunner.validate(ParentRunner.java:344) [arquillian-junit.jar:]

                          at org.junit.runners.ParentRunner.<init>(ParentRunner.java:74) [arquillian-junit.jar:]

                          at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:55) [arquillian-junit.jar:]

                          at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:13) [arquillian-junit.jar:]

                          at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57) [arquillian-junit.jar:]

                          at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29) [arquillian-junit.jar:]

                          at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57) [arquillian-junit.jar:]

                          at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24) [arquillian-junit.jar:]

                          at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:33) [arquillian-junit.jar:]

                          at org.junit.runner.JUnitCore.run(JUnitCore.java:136) [arquillian-junit.jar:]

                          at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65) [arquillian-junit.jar:]

                          at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethodInternal(JMXTestRunner.java:128)

                          at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethod(JMXTestRunner.java:107)

                          at org.jboss.as.arquillian.service.ArquillianService$ExtendedJMXTestRunner.runTestMethod(ArquillianService.java:226)

                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_23]

                          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_23]

                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_23]

                          at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_23]

                          at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:93) [rt.jar:1.6.0_23]

                          at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:27) [rt.jar:1.6.0_23]

                          at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:208) [rt.jar:1.6.0_23]

                          at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:120) [rt.jar:1.6.0_23]

                          at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:262) [rt.jar:1.6.0_23]

                          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836) [rt.jar:1.6.0_23]

                          at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761) [rt.jar:1.6.0_23]

                          at org.jboss.as.jmx.PluggableMBeanServerImpl$TcclMBeanServer.invoke(PluggableMBeanServerImpl.java:489)

                          at org.jboss.as.jmx.PluggableMBeanServerImpl.invoke(PluggableMBeanServerImpl.java:243)

                          at org.jboss.remoting3.jmx.protocol.v1.ServerProxy$InvokeHandler.handle(ServerProxy.java:1034)

                          at org.jboss.remoting3.jmx.protocol.v1.ServerProxy$MessageReciever$1.run(ServerProxy.java:215)

                          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_23]

                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_23]

                          at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_23]

                      • 8. Re: Two @OperateOnDeployment annotation in test
                        aslak

                        This works for me:

                         

                         

                        package com.acme.ejb.multi;
                        
                        
                        import javax.naming.InitialContext;
                        import javax.naming.NamingException;
                        
                        
                        import org.jboss.arquillian.container.test.api.Deployment;
                        import org.jboss.arquillian.container.test.api.OperateOnDeployment;
                        import org.jboss.arquillian.container.test.api.OverProtocol;
                        import org.jboss.arquillian.junit.Arquillian;
                        import org.jboss.arquillian.test.api.ArquillianResource;
                        import org.jboss.shrinkwrap.api.Archive;
                        import org.jboss.shrinkwrap.api.ShrinkWrap;
                        import org.jboss.shrinkwrap.api.spec.JavaArchive;
                        import org.jboss.shrinkwrap.api.spec.WebArchive;
                        import org.junit.Test;
                        import org.junit.runner.RunWith;
                        
                        
                        @RunWith(Arquillian.class)
                        public class PostConstructTC {
                            
                            @ArquillianResource
                            InitialContext ctx;
                        
                            @OverProtocol("Servlet 3.0")
                            @Deployment(managed=true, testable = true, name = "postconstruct", order = 1)
                            public static Archive<?> deploy() {
                                return ShrinkWrap.create(WebArchive.class)
                                        .addAsLibraries(
                                                ShrinkWrap.create(JavaArchive.class, "postconstruct.jar")
                                                    .addClasses(CountedSessionBean.class));
                            }
                            
                            @OverProtocol("Servlet 3.0")
                            @Deployment(managed=true, testable = true, name = "postconstruct2", order = 2)
                            public static Archive<?> deploy2() {
                                return ShrinkWrap.create(WebArchive.class)
                                        .addAsLibraries(
                                                ShrinkWrap.create(JavaArchive.class, "postconstruct2.jar")
                                                    .addClasses(CountedSessionBean2.class));
                            }
                            
                            @Test
                            @OperateOnDeployment("postconstruct")
                            public void test() throws NamingException {
                                CountedSessionBean bean = (CountedSessionBean) ctx.lookup("java:module/" + CountedSessionBean.class.getSimpleName());
                                bean.doSomething();
                            }
                            
                            @Test
                            @OperateOnDeployment("postconstruct2")
                            public void test2() throws NamingException {
                                CountedSessionBean2 bean = (CountedSessionBean2) ctx.lookup("java:module/" + CountedSessionBean2.class.getSimpleName());
                                bean.doSomething();
                            }
                        }
                        
                        

                         

                         

                        notes:

                         

                          * changed to deploy as WebArchives to avoid error when two "test.war"'s being deployed (default created name by the Servlet Protocol)

                           * changed to lookup using java:module/ to avoid having to specify the auto generated war name e.g. 11bb3a01-e1fa-4029-b124-735ea2bec0f5

                           * both deployments use OverProtocol(Servlet 3.0), but only having it on one of them work as well

                        • 9. Re: Two @OperateOnDeployment annotation in test
                          ochaloup

                          Thank you, that's the way which I didn't figure out.

                          • 10. Re: Two @OperateOnDeployment annotation in test
                            aslak

                            Would you be so kind to report the multi deployment issue with the AS7 protocol?

                             

                            https://issues.jboss.org/browse/AS7 on the TestSuite component.

                             

                            -aslak-

                            • 11. Re: Two @OperateOnDeployment annotation in test
                              ochaloup
                              • 12. Re: Two @OperateOnDeployment annotation in test
                                aslak

                                thank you!