0 Replies Latest reply on Nov 25, 2011 7:00 AM by Tommy Tynjä

    Arquillian MDB test with JBoss 5.1.0

    Tommy Tynjä Newbie

      Hi.

       

      I'm trying to test a simple MDB with Arquillian on a JBoss 5.1.0.GA managed container. However, I can't seem to get the bean injected to my test case. A corresponding physical artifact is manually deployable on the server, the MDB deployed and bound in JNDI etc. When running with Arquillian, the MDB seems to be deployed and bound to JNDI, but the lookup fails? Does anyone have a clue on what I'm doing wrong here?

       

      Is it possible to have something to do with: http://community.jboss.org/thread/173150?tstart=0 ?

       

      I didn't manage to get the wiki markup working, sorry for that. Any help appreciated.

       

      Relevant dependencies:

       

              <dependency>

                  <groupId>org.jboss.arquillian.junit</groupId>

                  <artifactId>arquillian-junit-container</artifactId>

                  <version>1.0.0.CR4</version>

                  <scope>test</scope>

              </dependency>

              <dependency>

                  <groupId>org.jboss.arquillian.container</groupId>

                  <artifactId>arquillian-jbossas-managed-5.1</artifactId>

                  <version>1.0.0.CR2</version>

                  <scope>test</scope>

              </dependency>

              <dependency>

                  <groupId>org.jboss.jbossas</groupId>

                  <artifactId>jboss-server-manager</artifactId>

                  <version>1.0.3.GA</version>

                  <scope>test</scope>

              </dependency>

              <dependency>

                  <groupId>org.jboss.jbossas</groupId>

                  <artifactId>jboss-as-client</artifactId>

                  <version>5.1.0.GA</version>

                  <type>pom</type>

                  <scope>test</scope>

              </dependency>

       

      My MDB:

       

      package foo.bar.ejb;

       

      import javax.ejb.ActivationConfigProperty;

      import javax.ejb.MessageDriven;

      import javax.jms.Message;

      import javax.jms.MessageListener;

       

      @MessageDriven(name = "foo.bar.ejb.MyMDB", activationConfig = {

              @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),

              @ActivationConfigProperty(propertyName = "destination", propertyValue = "/queue/JMSXXX"),

              @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "AUTO_ACKNOWLEDGE"),

              @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1") })

      public class MyMDB implements MessageListener {

          @Override

          public void onMessage(final Message message) {

          }

      }

       

      My test case:

       

      @RunWith(Arquillian.class)

      public class TestMyMDB {

       

          @Deployment(order = 1)

          public static org.jboss.shrinkwrap.descriptor.api.Descriptor deployQueue() {

              return new MyQueueDescriptor();

          }

       

          @Deployment(order = 2)

          public static Archive createArchive() {

              JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "test-ejb.jar")

                      .addClass(MessageListener.class)

                      .addClass(MyMDB.class)

                      .addClass(org.jboss.shrinkwrap.descriptor.api.Descriptor.class)

                      .addClass(MyQueueDescriptor.class)

                      .addClass(TestMessage.class);

       

              ejbJar.writeTo(System.out, Formatters.VERBOSE);

              return ejbJar;

          }

       

          @EJB(mappedName = "foo.bar.ejb.MyMDB")

          private MessageListener myMDB;

       

          @Test

          public void mySimpleTestCase() {

              myMDB.onMessage(new TestMessage());

          }

      }

       

      Relevant parts from server.log:

       

      DEBUG [org.jboss.deployment.MappedReferenceMetaDataResolverDeployer] (WorkerThread#1[127.0.0.1:4583]) vfszip:/D:/servers/jboss-5.1.0.GA/server/default/deploy/test.ear/ endpoint mappings:

        + ejb/test-ejb.jar#foo.bar.ejb.MyMDB -> ContainerDependencyMetaData(deploymentPath=test-ejb.jar,componentName=foo.bar.ejb.MyMDB,containerName=null,jndiNames=[null],jndiAliasDepends=[],targets=[],jndiDepends=[])

       

      DEBUG [org.jboss.deployment.MappedReferenceMetaDataResolverDeployer] (WorkerThread#1[127.0.0.1:4583]) Processing unit=test-ejb.jar, structure:

      test.ear

       

      +test-ejb.jar

      ++EjbEndpoint:ejbName=foo.bar.ejb.MyMDB,ejbClass=foo.bar.ejb.MyMDB

       

      +arquillian-protocol.war

       

       

      DEBUG [org.jboss.deployment.MappedReferenceMetaDataResolverDeployer] (WorkerThread#1[127.0.0.1:4583]) Processing unit=arquillian-protocol.war, structure:

      test.ear

       

      +test-ejb.jar

      ++EjbEndpoint:ejbName=foo.bar.ejb.MyMDB,ejbClass=foo.bar.ejb.MyMDB

       

      +arquillian-protocol.war

       

       

      INFO  [org.jboss.ejb3.deployers.Ejb3DependenciesDeployer] (WorkerThread#1[127.0.0.1:4583]) Encountered deployment AbstractVFSDeploymentContext@2484490{vfszip:/D:/servers/jboss-5.1.0.GA/server/default/deploy/test.ear/test-ejb.jar/}

      INFO  [org.jboss.ejb3.deployers.Ejb3DependenciesDeployer] (WorkerThread#1[127.0.0.1:4583]) Encountered deployment AbstractVFSDeploymentContext@2484490{vfszip:/D:/servers/jboss-5.1.0.GA/server/default/deploy/test.ear/test-ejb.jar/}

      DEBUG [org.jboss.ejb3.deployers.Ejb3Deployer] (WorkerThread#1[127.0.0.1:4583]) ********* Ejb3Deployer Begin Unit: test.ear jar: test.ear

      DEBUG [org.jboss.ejb3.Ejb3Deployment] (WorkerThread#1[127.0.0.1:4583]) EJB3 deployment time took: 78

      DEBUG [org.jboss.ejb3.deployers.Ejb3Deployer] (WorkerThread#1[127.0.0.1:4583]) ********* Ejb3Deployer Begin Unit: test-ejb.jar jar: test-ejb.jar

      DEBUG [org.jboss.ejb3.interceptors.metadata.InterceptorMetaDataBridge] (WorkerThread#1[127.0.0.1:4583]) ======> Creating interceptor metadata bridge

      DEBUG [org.jboss.ejb3.security.AuthenticationInterceptorFactory] (WorkerThread#1[127.0.0.1:4583]) Creating interceptor with authentication manager 'null'

      DEBUG [org.jboss.ejb3.Ejb3AnnotationHandler] (WorkerThread#1[127.0.0.1:4583]) found EJB3: ejbName=foo.bar.ejb.MyMDB, class="foo".bar.ejb.MyMDB, type=MESSAGE_DRIVEN

      DEBUG [org.jboss.ejb3.Ejb3Registry] (WorkerThread#1[127.0.0.1:4583]) Registered container jboss.j2ee:ear=test.ear,jar=test-ejb.jar,name=foo.bar.ejb.MyMDB,service=EJB3,VMID=bbcf02923a5b4e91:20ba7fb1:133da7939d9:-7ff9

      DEBUG [org.jboss.ejb3.Ejb3Deployment] (WorkerThread#1[127.0.0.1:4583]) EJB3 deployment time took: 16

      DEBUG [org.jboss.ejb3.interceptors.registry.InterceptorRegistry] (WorkerThread#1[127.0.0.1:4583]) Found default interceptors []

      DEBUG [org.jboss.ejb3.interceptors.registry.InterceptorRegistry] (WorkerThread#1[127.0.0.1:4583]) Found class interceptors []

      INFO  [org.jboss.ejb3.deployers.JBossASKernel] (WorkerThread#1[127.0.0.1:4583]) Created KernelDeployment for: test-ejb.jar

      INFO  [org.jboss.ejb3.deployers.JBossASKernel] (WorkerThread#1[127.0.0.1:4583]) installing bean: jboss.j2ee:ear=test.ear,jar=test-ejb.jar,name=foo.bar.ejb.MyMDB,service=EJB3

      INFO  [org.jboss.ejb3.deployers.JBossASKernel] (WorkerThread#1[127.0.0.1:4583])   with dependencies:

      INFO  [org.jboss.ejb3.deployers.JBossASKernel] (WorkerThread#1[127.0.0.1:4583])   and demands:

      INFO  [org.jboss.ejb3.deployers.JBossASKernel] (WorkerThread#1[127.0.0.1:4583])     jboss.ejb:service=EJBTimerService

      INFO  [org.jboss.ejb3.deployers.JBossASKernel] (WorkerThread#1[127.0.0.1:4583])   and supplies:

      INFO  [org.jboss.ejb3.deployers.JBossASKernel] (WorkerThread#1[127.0.0.1:4583])     jndi:null

      INFO  [org.jboss.ejb3.deployers.JBossASKernel] (WorkerThread#1[127.0.0.1:4583])     Class:javax.jms.MessageListener

      INFO  [org.jboss.ejb3.deployers.JBossASKernel] (WorkerThread#1[127.0.0.1:4583]) Added bean(jboss.j2ee:ear=test.ear,jar=test-ejb.jar,name=foo.bar.ejb.MyMDB,service=EJB3) to KernelDeployment of: test-ejb.jar

      DEBUG [org.jboss.ejb3.Ejb3Deployment] (WorkerThread#1[127.0.0.1:4583]) Bound ejb3 container jboss.j2ee:ear=test.ear,jar=test-ejb.jar,name=foo.bar.ejb.MyMDB,service=EJB3

      ...

      INFO  [org.jboss.ejb3.EJBContainer] (WorkerThread#1[127.0.0.1:4583]) STARTED EJB: foo.bar.ejb.MyMDB ejbName: foo.bar.ejb.MyMDB

      ...

      FINE  [org.jboss.arquillian.test.spi.TestEnricher] (http-localhost%2F127.0.0.1-8080-1) Could not lookup @javax.ejb.EJB(beanName=, mappedName=foo.bar.ejb.MyMDB, beanInterface=class java.lang.Object, description=, name=), other Enrichers might, move on. Exception: No EJB found in JNDI, tried the following names: foo.bar.ejb.MyMDB,

       

       

      Stack trace:

       

      java.lang.NullPointerException

          at foo.bar.ejb.TestMyMDB.mySimpleTestCase(TestMyMDB.java:42)

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

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

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

          at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)

          at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

          at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)

          at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:246)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:290)

          at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:45)

          at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:216)

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

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

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

          at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:290)

          at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:45)

          at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:175)

          at org.junit.runners.ParentRunner.run(ParentRunner.java:236)

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

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

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

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

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

          at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

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

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

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

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

          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)

          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)

          at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)

          at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)

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

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

          at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)

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

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

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

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

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

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