1 2 Previous Next 16 Replies Latest reply on Mar 30, 2012 8:41 AM by reschifl

    Arquillian with EAR classloading isolation

    gboro54

      I am trying to test an EJB jar wrapped in an EAR. The problem is without adding the application.xml it would appear as thought my jboss-deployment-structure.xml is ignored(resulting in classloading exceptions). However when I add this to the EAR I get the following exception:

       

       

      {code}

      java.lang.IllegalStateException: Error launching test com.common.rules.RulesSessionPopulatorTest public void com.common.rules.RulesSessionPopulatorTest.testAllNotNull()

                at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:122)

                at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:120)

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

                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                at java.lang.reflect.Method.invoke(Unknown Source)

                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.ClientTestExecuter.execute(ClientTestExecuter.java:57)

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

                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                at java.lang.reflect.Method.invoke(Unknown Source)

                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.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142)

                at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createTestContext(ContainerEventController.java:129)

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

                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                at java.lang.reflect.Method.invoke(Unknown Source)

                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.createTestContext(TestContextHandler.java:89)

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

                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                at java.lang.reflect.Method.invoke(Unknown Source)

                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(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                at java.lang.reflect.Method.invoke(Unknown Source)

                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(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                at java.lang.reflect.Method.invoke(Unknown Source)

                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.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)

                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)

                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)

                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)

                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)

                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)

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

                at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)

                at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

                at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

      Caused by: java.lang.IllegalStateException: Error launching request at http://127.0.0.1:8080/test/ArquillianServletRunner?outputMode=serializedObject&className=com.common.rules.RulesSessionPopulatorTest&methodName=testAllNotNull. No result returned

                at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.executeWithRetry(ServletMethodExecutor.java:158)

                at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:118)

                ... 75 more

       

       

      {code}

       

      This is caused because an entry is added for test.war which sets the context root to test.war. I am using 1.0.0.CR7 with this exception

        • 1. Re: Arquillian with EAR classloading isolation
          reschifl

          Hello,

           

          I ran into the same error.

           

          Did you solve this problem?

           

          Regards,

          Lars

          • 2. Re: Arquillian with EAR classloading isolation
            aslak

            Your running into ARQ-670, it should be fixed in HEAD, and will be out in CR8 (today ish.. )

             

            https://github.com/arquillian/arquillian-core/commit/31bdac00c929f98e58d4a9fd0dae8c23f8ca9527

             

            https://issues.jboss.org/browse/ARQ-670

            • 3. Re: Arquillian with EAR classloading isolation
              aslak

              The latest 1.0.0.Final-SNAPSHOT should hvae this fix in it..

               

              just remmeber to use the arquillian-bom in dependencyManagement section to upgrade the contianer dependencies to the new Core v.

              https://gist.github.com/1154075

              • 4. Re: Arquillian with EAR classloading isolation
                reschifl

                I changed my maven parent to use 1.0.0.Final-SNAPSHOT of the arquillian-bom and added the jboss developer repository.

                This downloaded a build from 2012-03-19.

                 

                But the error is still there. Are you sure that this error belongs to ARQ-670?

                 

                Regards,

                Lars

                • 5. Re: Arquillian with EAR classloading isolation
                  aslak

                  Maybe I missunderstood the issue..  Could you provide me with a test project?

                  • 6. Re: Arquillian with EAR classloading isolation
                    reschifl

                    I created a sample project on github: https://github.com/lfischer/arquillian-problem

                     

                    Simply run "mvn clean test". This fails with a similar error like the one from the first post.

                     

                    There are two test classes:

                    • JarTest uses a JavaArchive. This is working fine.
                    • EarTest uses an EnterpriseArchive build from an existing .ear. This one fails.

                     

                    Regards,

                    Lars

                    • 7. Re: Arquillian with EAR classloading isolation
                      aslak

                      Thank you!

                       

                      https://github.com/lfischer/arquillian-problem/pull/1

                       

                      • ARQ-670 add the wrong contextRoot name for test.war so request never reach the server
                      • When updating to 1.0.0.Final-SNAPSHOT where ARQ-670 is fixed, it fails with ClassNotFoundException EarTest.class. When deploying multi module deployments, Arquillian does not automatically add the TestClass.
                      • Application names change when doing the full build import, so JNDI names change as well.
                      • 8. Re: Arquillian with EAR classloading isolation
                        reschifl

                        Thank you too, for correcting my example!

                        • 9. Re: Arquillian with EAR classloading isolation
                          reschifl

                          Hello Aslak,

                           

                          the corrected sample project runs fine, but my real project still fails with this error.

                           

                          I replaced the @Deployment method of the failing test with the sourcecut from the example and commented every @EJB out. This also runns fine, because it deploys the (useless) example .ear.

                           

                          After ONLY changing the maven coordinates string to the real .ear artefact, the error returns. So there must be an additional difference inside the .ear files build by maven.

                          I compared them, but I don't get it.

                           

                          Do you have any hint, where to search for the reason?

                           

                          This is my error log:

                           

                          -------------------------------------------------------------------------------
                          Test set: com.ibykus.apx.incubator.pt.runtime.jee.Ear2Test
                          -------------------------------------------------------------------------------
                          Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 17.326 sec <<< FAILURE!
                          injectEJBFromEar(com.ibykus.apx.incubator.pt.runtime.jee.Ear2Test)  Time elapsed: 1.108 sec  <<< ERROR!
                          java.lang.IllegalStateException: Error launching test com.ibykus.apx.incubator.pt.runtime.jee.Ear2Test public void com.ibykus.apx.incubator.pt.runtime.jee.Ear2Test.injectEJBFromEar() throws java.lang.Exception
                              at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:122)
                              at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:120)
                              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:135)
                              at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
                              at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
                              at org.jboss.arquillian.container.test.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:57)
                              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.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142)
                              at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createTestContext(ContainerEventController.java:129)
                              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.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:135)
                              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.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)
                              at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
                              at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
                              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.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
                              at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
                              at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
                              at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
                              at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
                          Caused by: java.lang.IllegalStateException: Error launching request at http://127.0.0.1:8080/runtime.jee/ArquillianServletRunner?outputMode=serializedObject&className=com.ibykus.apx.incubator.pt.runtime.jee.Ear2Test&methodName=injectEJBFromEar. No result returned
                              at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.executeWithRetry(ServletMethodExecutor.java:158)
                              at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:118)
                              ... 81 more
                          

                           

                           

                          Regards,

                          Lars

                          • 10. Re: Arquillian with EAR classloading isolation
                            reschifl

                            Uh, very strange... I reduced the content of my real .ear step by step, but the logfile shows me that non existing EJBs were deployed. So I bumped the SNAPSHOT version up to the next point version. And now the tests run.

                             

                            Why are new SNAPSHOT versions not recognized, when resolving Maven dependencies? Or does the JBoss cache deployed artefacts?

                             

                            I still don't know, what the difference is, but I will retry to reduce the contents.

                            • 11. Re: Arquillian with EAR classloading isolation
                              reschifl

                              Ok, I think I found the difference:

                               

                              my real .ear contains an .war and the application.xml sets the context root to "/".

                               

                              If I change this to something other, the tests run fine. Is this the same as described in ARQ-670?

                               

                              Regards,

                              Lars

                              • 12. Re: Arquillian with EAR classloading isolation
                                reschifl

                                Ok, last part of my monologue

                                 

                                I think, I found a bug:

                                 

                                the MavenDependencyResolver always overwrites the SNAPSHOT version placed on the local maven repository with the latest from the remote repository managers.

                                 

                                This is why my tests failed: I build new SNAPSHOT versions of my real .ear using "mvn install" This places a new file inside the local maven repo.

                                Starting the tests, the MavenDependencyResolver loads an old SNAPSHOT .ear from the remote maven server and replaced the content of the local maven repo. Now the tests run always with the old version.

                                 

                                Is this a kown bug?

                                 

                                Regards,

                                Lars

                                • 13. Re: Arquillian with EAR classloading isolation
                                  aslak

                                  Yes, i believe this bug is fixed in the 2.0.0.alpha-1 release..

                                   

                                  Include this pom in your project to upgrade the Resolver version(note, a few api changes)

                                  https://repository.jboss.org/nexus/content/groups/public/org/jboss/shrinkwrap/resolver/shrinkwrap-resolver-depchain/2.0.0-alpha-1/

                                   

                                  This version should also be able to package a 'maven artifact' directly from the workspace without having to go via the local/remote repository

                                  • 14. Re: Arquillian with EAR classloading isolation
                                    aslak

                                    Hmm.. I remember a / mapping issue earlier on, but I believe that should have been fixed.

                                     

                                    Does your arq-problem project reflect this change? I can have a look..

                                    1 2 Previous Next