3 Replies Latest reply on Jul 10, 2007 6:56 AM by marilenc

    EJB3 MDB One Implementation Multiple Deployments

    jlowcock

      I have a use case where the same MessageDriven bean needs to be deployed twice to listen to more than one Topic.

      The code for the bean is:

      @MessageDriven
      ( activationConfig=
      {
      @ActivationConfigProperty(propertyName="messagingType",propertyValue="javax.jms.MessageListener")
      }
      )
      public class JmsConnectorBean
      implements MessageListener
      {
      public void onMessage(Message msg)
      {
      System.out.println(msg);
      }
      }

      Other than repeating the code the only correct way that I can see to satisfy the use case is to use the ejb-jar.xml deployment descriptor which is as follows:

      <message-driven>
      <ejb-name>JmsConnectorBean</ejb-name>
      <ejb-class>com.agilyx.adaptive.jms.JmsConnectorBean</ejb-class>
      <transaction-type>Container</transaction-type>
      <activation-config>
      <activation-config-property>
      <activation-config-property-name>destinationType</activation-config-property-name>
      <activation-config-property-value>javax.jms.Topic</activation-config-property-value>
      </activation-config-property>
      <activation-config-property>
      <activation-config-property-name>destination</activation-config-property-name>
      <activation-config-property-value>topic/onique/adaptive/notifier</activation-config-property-value>
      </activation-config-property>
      </activation-config>
      </message-driven>
      <message-driven>
      <ejb-name>JmsDemoConnectorBean</ejb-name>
      <ejb-class>com.agilyx.adaptive.jms.JmsConnectorBean</ejb-class>
      <transaction-type>Container</transaction-type>
      <activation-config>
      <activation-config-property>
      <activation-config-property-name>destinationType</activation-config-property-name>
      <activation-config-property-value>javax.jms.Topic</activation-config-property-value>
      </activation-config-property>
      <activation-config-property>
      <activation-config-property-name>destination</activation-config-property-name>
      <activation-config-property-value>topic/onique/adaptive/notifier</activation-config-property-value>
      </activation-config-property>
      </activation-config>
      </message-driven>

      This also works well. However if there is not a descriptor for the MDB with the same default name as that in the implementation class the deployment fails with the following trace:

      16:25:29,640 WARN [ServiceController] Problem starting service jboss.j2ee:jar=adaptive-server-ejb.jar,name=JmsConnectorBean,service=EJB3
      org.jboss.deployment.DeploymentException: Required config property RequiredConfigPropertyMetaData@180e7a4[name=destinationType descriptions=[DescriptionMetaData@1a51364[language=en]]] for messagingType 'javax.jms.MessageListener' not found in activation config [] ra=jboss.jca:service=RARDeployment,name='jms-ra.rar'
      at org.jboss.resource.deployment.ActivationSpecFactory.createActivationS
      pec(ActivationSpecFactory.java:95)
      at org.jboss.resource.deployment.RARDeployment.createActivationSpec(RARD
      eployment.java:254)
      at org.jboss.resource.deployment.RARDeployment.internalInvoke(RARDeploym
      ent.java:218)
      at org.jboss.system.ServiceDynamicMBeanSupport.invoke(ServiceDynamicMBea
      nSupport.java:156)
      at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:1
      64)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.ejb3.JmxClientKernelAbstraction.invoke(JmxClientKernelAbstr
      action.java:44)
      at org.jboss.ejb3.mdb.inflow.JBossMessageEndpointFactory.createActivatio
      nSpec(JBossMessageEndpointFactory.java:285)
      at org.jboss.ejb3.mdb.inflow.JBossMessageEndpointFactory.start(JBossMess
      ageEndpointFactory.java:189)
      at org.jboss.ejb3.mdb.MessagingContainer.startProxies(MessagingContainer
      .java:185)
      at org.jboss.ejb3.mdb.MessagingContainer.start(MessagingContainer.java:1
      51)
      at org.jboss.ejb3.mdb.MDB.start(MDB.java:126)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWra
      pper.java:102)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanS
      upport.java:289)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
      eanSupport.java:245)
      at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
      ler.java:978)
      at $Proxy0.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:417)
      at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
      at $Proxy258.start(Unknown Source)
      at org.jboss.ejb3.JmxKernelAbstraction.install(JmxKernelAbstraction.java
      :96)
      at org.jboss.ejb3.Ejb3Deployment.registerEJBContainer(Ejb3Deployment.jav
      a:281)
      at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:328)
      at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:91)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanS
      upport.java:289)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
      eanSupport.java:245)
      at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
      ler.java:978)
      at $Proxy0.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:417)
      at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
      at $Proxy37.start(Unknown Source)
      at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:449)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
      or.java:133)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
      BeanOperationInterceptor.java:142)
      at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor
      .java:97)
      at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(Intercepto
      rServiceMBeanSupport.java:238)
      at org.jboss.ws.integration.jboss.DeployerInterceptor.start(DeployerInte
      rceptor.java:92)
      at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.
      start(SubDeployerInterceptorSupport.java:188)
      at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterce
      ptor.java:95)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
      at $Proxy38.start(Unknown Source)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
      at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
      or.java:133)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
      BeanOperationInterceptor.java:142)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
      at $Proxy6.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
      tScanner.java:421)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
      canner.java:610)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      doScan(AbstractDeploymentScanner.java:263)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      loop(AbstractDeploymentScanner.java:274)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      run(AbstractDeploymentScanner.java:225)

      So it seems that there must be one and one only descriptor with the same name as the implementation class to correctly pick up and apply the deployment decriptors.

      So my question is whether this is a bug or am I misunderstanding what or how to deploy with ejb0jar.xml ?

        • 1. Re: EJB3 MDB One Implementation Multiple Deployments

          Just guessing here: Have you removed the annotations?

          Otherwise I think the MDB would get deployed thrice: Twice after the deployment descriptor and once by annoatations. The last one will fail then because the annotations are incomplete.

          Regards

          Felix

          • 2. Re: EJB3 MDB One Implementation Multiple Deployments
            jlowcock

            So obvious when you take a step back from the problem. The deployment via the incomplete annotations is the problem. Thanks for the pointer.

            • 3. Re: EJB3 MDB One Implementation Multiple Deployments
              marilenc

              Thank you very much for this post. I was searching in vain to find a way to move quartz adnotations to ejb-jar.xml and your post was helpfull.

              <?xml version="1.0" encoding="UTF-8"?>
              <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
               http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1">
               <enterprise-beans>
               <message-driven>
               <ejb-name>Test</ejb-name>
               <ejb-class>Test</ejb-class>
               <messaging-type>org.quartz.Job</messaging-type>
               <transaction-type>Container</transaction-type>
               <activation-config>
               <activation-config-property>
               <activation-config-property-name>cronTrigger</activation-config-property-name>
               <activation-config-property-value>
               <![CDATA[0/2 * * * * ?]]>
               </activation-config-property-value>
               </activation-config-property>
               </activation-config>
               </message-driven>
               </enterprise-beans>
              </ejb-jar>


              Here is a full link to my problem and solution http://www.len.ro/work/articles/jboss/creating-a-quartz-job for anyone needing.