12 Replies Latest reply on Nov 5, 2012 4:30 AM by Arnold Johansson

    EAR-deployment with remote JBoss: "Cannot obtain Arquillian config"

    Christoph Rohr Newbie

      Hello

       

      I just want to access some local EJBs in a remote JBoss containter with Arquillian. All works fine as long as I deploy my EJBs in a simple JAR. But as soon as I switch to an EAR-deployment, Arquillian couldn’t obtain the Arquillian config for my EJB and the tests aborts with an exception after a timeout:

       

      java.lang.IllegalStateException: Cannot obtain Arquillian config for: ch.test.arquillian.HelloEJBTest

              at org.jboss.as.arquillian.service.ArquillianService.getArquillianConfig(ArquillianService.java:183)

              at org.jboss.as.arquillian.service.ArquillianService.getArquillianConfig(ArquillianService.java:193)

              at org.jboss.as.arquillian.service.ArquillianService.access$300(ArquillianService.java:69)

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

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

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

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

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

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

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

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

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

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

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

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

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

              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

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

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

       

      I’m really out of ideas, how to fix this problem.

       

      It would be really great if you could give me some hint what I might be doing wrong!

      In the attachement, I’ve added my small sample project.

       

      Thanks a lot,

      Christoph

        • 1. Re: EAR-deployment with remote JBoss: "Cannot obtain Arquillian config"
          Bartosz Majsak Master

          I think this might be related to this issue https://issues.jboss.org/browse/AS7-1696

           

          Try using Servlet protocol instead of JMX by adding following element in the arquillian.xml:

          <defaultProtocol type="Servlet 3.0" />

           

          I hope this will solve the problem


          • 2. Re: EAR-deployment with remote JBoss: "Cannot obtain Arquillian config"
            Christoph Rohr Newbie

            Thanks for the hint!

             

            I've defined the defaultProtocol in my arquillian.xml and added the following maven dependency in my pom.xml:

               <dependency>
               <groupId>org.jboss.arquillian.protocol</groupId>
               <artifactId>arquillian-protocol-servlet</artifactId>
               <version>1.0.1.Final</version>
               <scope>test</scope>
              </dependency>

            Arquillian seems now to communicate over the Servlet protocol. But the test couln't still be executed. What I get now is the following exception:

            java.lang.IllegalStateException: Error launching test ch.test.arquillian.HelloEJBTest public void ch.test.arquillian.HelloEJBTest.testHelloEJB()
            at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:126)
            at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:120)
            (...)

            Caused by: java.lang.IllegalStateException: Error launching request at http://127.0.0.1:8080/test/ArquillianServletRunner?outputMode=serializedObject&className=ch.test.arquillian.HelloEJBTest&methodName=testHelloEJB. No result returned
            at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.executeWithRetry(ServletMethodExecutor.java:162)
            at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:122)
            ... 75 more

             

            Do you have any idea?

            • 3. Re: EAR-deployment with remote JBoss: "Cannot obtain Arquillian config"
              Bartosz Majsak Master

              Hi Christoph,

               

              first, good news: I managed to make your test running

               

              But it wasn't as straightforward as I thought.

               

              First thing which was wrong with your deployment - you were adding jar as Module, whereas you should add it as library.

               

              But after doing that I got hit hard by following exception:

               

              {code}java.lang.ClassNotFoundException: ch.test.arquillian.HelloEJBTest from [Module "deployment.test.ear.test.war:main" from Service Module Loader]{code}

               

              So I added the test class itself to the jar, and then I got this nice exception:

               

               

              {code}Caused by: java.lang.IllegalArgumentException: JBAS016066: Could not resolve @EJB injection for @javax.ejb.EJB(beanName=, mappedName=, beanInterface=class java.lang.Object, description=, name=, lookup=) on private ch.test.arquillian.HelloEJB ch.test.arquillian.HelloEJBTest.helloEJB{code}

               

              So eventually I modified two more things:

              - injected component under test using @Inject instead of @EJB

              - added empty beans.xml to the test jar

               

              Final form of the deployment method looks as follows:

               

              {code:java}

              @Deployment                                                                                           

              public static Archive<?> createTestArchive() {                                                        

               

                final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "test.jar")                            

                                                  .addClasses(HelloEJB.class, HelloEJBBean.class, HelloEJBTest.class)

                                                  .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");         

               

                final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "test.ear")                

                                                        .addAsLibrary(jar);                                         

               

                return ear;                                                                                         

              }                                                                                                     

              {code}

               

              And finally I got the green bar!

               

              However it should be more straigthforward. I will try to check with Aslak, maybe he has some insight which party is causing this strange behaviour (might be the container adapter implementation, which is my god feeling).

               

              Attached full project with slightly updated pom.xml

              1 of 1 people found this helpful
              • 4. Re: EAR-deployment with remote JBoss: "Cannot obtain Arquillian config"
                Christoph Rohr Newbie

                Hello Bartosz

                 

                Great, I could execute the test on my (new) machine and the test was green!

                I agree that the way to get there is a bit tricky, but at least we could now go ahead and use Arquillian in our project.

                 

                I hope you tell me if you found an easier solution for this (common?) use case.

                 

                Thanks a lot for your great help!

                Christoph

                • 5. Re: EAR-deployment with remote JBoss: "Cannot obtain Arquillian config"
                  Bartosz Majsak Master

                  I'm glad that it worked for you

                   

                  I will try to find why the common approach does not work in this case and will let you know about the findings / solution.

                   

                  Cheers,

                  Bartosz

                  • 6. Re: EAR-deployment with remote JBoss: "Cannot obtain Arquillian config"
                    Christoph Rohr Newbie

                    Hello Bartosz

                     

                    Since your last post, I went on with my current project and tried to build some tests with Arqullian that are a little bit more complex. Thereby I got stuck if I tried to inject an EJB with @EJB into my system under test.

                    I've modified the discussed example of this thread to show the problem (refer to attached arquillian-ear-02.zip).

                     

                    When I run the test, I always get the following exception you already discovered when injecting an EJB with @EJB into the test class:

                    java.lang.RuntimeException: Could not inject members

                    at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectClass(CDIInjectionEnricher.java:135)

                    at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.enrich(CDIInjectionEnricher.java:78)

                    at org.jboss.arquillian.test.impl.TestInstanceEnricher.enrich(TestInstanceEnricher.java:52)

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

                    ...

                    Caused by: java.lang.IllegalArgumentException: JBAS016066: Could not resolve @EJB injection for @javax.ejb.EJB(beanName=, mappedName=, beanInterface=class java.lang.Object, description=, name=, lookup=) on private ch.test.arquillian.ConverterBean ch.test.arquillian.HelloEJBBean.helloEjb02

                    at org.jboss.as.weld.services.bootstrap.WeldEjbInjectionServices.resolveEjb(WeldEjbInjectionServices.java:111)

                    at org.jboss.weld.util.Beans.injectEEFields(Beans.java:620)

                    at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:160)

                    ...

                     

                    For me, it looks like Arquillian could not handle @EJB annotations together with an EAR-deployment at all. Do you have any further idea how we could resolve this problem?

                     

                    Thanks a lot,

                    Christoph

                    • 7. Re: EAR-deployment with remote JBoss: "Cannot obtain Arquillian config"
                      Bartosz Majsak Master

                      Hi Christoph,

                       

                      I'm not really sure what might wrong be with your current setup, but I will look at the attached project over the weekend. In the meantime - could you try to use @Inject instead of @EJB in tests (if it's only failing in the test class itself)?

                      • 8. Re: EAR-deployment with remote JBoss: "Cannot obtain Arquillian config"
                        Christoph Rohr Newbie

                        Hello Bartosz

                         

                        If I just test one isolated EJB, I could inject it with @Inject in my test class and it works fine.

                        But if this EJB depends on another (injected with @EJB), the test fails with the exception I've posted before...

                         

                        Thank's a lot for helping me. I'm looking forward to your analysis!

                        Christoph

                        • 9. Re: EAR-deployment with remote JBoss: "Cannot obtain Arquillian config"
                          Arnold Johansson Apprentice

                          *Bump*

                          Neither I can use @EJB. Any news on this?

                          /Arnold

                          • 10. Re: EAR-deployment with remote JBoss: "Cannot obtain Arquillian config"
                            Christoph Rohr Newbie

                            Hello Arnold

                             

                            We finally decided to use the CDI-way (@Inject) instead of @EJB in our project.

                             

                            Best regards

                            Christoph

                            • 11. Re: EAR-deployment with remote JBoss: "Cannot obtain Arquillian config"
                              Arnold Johansson Apprentice

                              Hi Christoph & Bartosz!

                               

                              Thanks for the feedback Christoph. Yes so do I where I can.

                              Really hope for support for @EJB in Arquillian (or whereever the problem lies) though, as I've got code that I'm not allowed to change.

                               

                              Have you got som more intel/roadmap/etc regarding this Bartosz?

                               

                              KR

                              /Arnold