3 Replies Latest reply on Nov 28, 2005 12:04 PM by William DeCoste

    How can I use EJB3/MDBs with the swiftmq-ivm.rar

    cleonhar Newbie

      Hi,

      I just try to register a MDB on a SwiftMQ-Queue. I found this example:

      http://wiki.jboss.org/wiki/Wiki.jsp?page=InboundSwiftMQ

      But this example is not using Annotations for the MDB. I tried the following example:

      @MessageDriven(activateConfig =
      {
       /*@ActivationConfigProperty(propertyName="providerAdapterJNDI",
       propertyValue="???"),
       */
       @ActivationConfigProperty(propertyName="destinationType",
       propertyValue="javax.jms.Queue"),
       @ActivationConfigProperty(propertyName="Destination",
       propertyValue="testqueue"),
       @ActivationConfigProperty(propertyName="SubscriptionDurability",
       propertyValue="Transacted"),
       @ActivationConfigProperty(propertyName="true",
       propertyValue="Xa"),
       @ActivationConfigProperty(propertyName="true",
       propertyValue="testqueue"),
       @ActivationConfigProperty(propertyName="DeliveryOption",
       propertyValue="B"),
       @ActivationConfigProperty(propertyName="MaxPoolSize",
       propertyValue="20"),
       @ActivationConfigProperty(propertyName="MaxMessages",
       propertyValue="1"),
       @ActivationConfigProperty(propertyName="ConnectionFactoryName",
       propertyValue="ConnectionFactory")
      })
      
      public class StatisticMessageReveiverService implements MessageListener {
      
      
      /* (non-Javadoc)
       * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
       */
      
      
      public void onMessage (Message msg) {
       System.out.println("GotMessage");
       }
      
       // ... ...
      }


      This example works with JBossMQ, but I have problems with SwiftMQ: Jboss can not find the DefaultJMSProvider. I can change the JNDI-Name with

      *@ActivationConfigProperty(propertyName="providerAdapterJNDI",
       propertyValue="NewJNDIName")
      


      But I don´t know to which value I should change it. Or do I need a addional jboss.xml to bind the swiftmq-ivm .rar to a JNDI-Name??

      Can anybody help me?

      Regards,
      Claus

        • 1. Re: How can I use EJB3/MDBs with the swiftmq-ivm.rar
          cleonhar Newbie

          Hi again,

          I tried now to bind the Resource-Adapter for swiftmq to the MDB using the jboss.xml and the ejb-jar.xml. Is this the right way? Or can I do it only with Annotations?

          I tried the following:

          ejb-jar.xml:

          <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://www.jboss.org/j2ee/dtd/ejb-jar_2_0.dtd">
          
          <ejb-jar >
           <enterprise-beans>
           <message-driven >
           <ejb-name>StatisticMessageReveiverService</ejb-name>
           <ejb-class>de.mobileview.mmstat.services.StatisticMessageReveiverService</ejb-class>
           <transaction-type>Container</transaction-type>
           </message-driven>
           </enterprise-beans>
          </ejb-jar>
          


          jboss.xml:

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
          
          <jboss>
           <enterprise-beans>
           <message-driven>
           <ejb-name>StatisticMessageReveiverService</ejb-name>
           <resource-adapter-name>swiftmq-ivm.rar</resource-adapter-name>
           </message-driven>
           </enterprise-beans>
          </jboss>
          


          But it seems the jboss.xml can not be parsed, because of the message-driven tag:

           at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:138)
           at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:173)
           at org.jboss.ejb3.Ejb3DescriptorHandler.parseDescriptors(Ejb3DescriptorHandler.java:443)
           at org.jboss.ejb3.Ejb3HandlerFactory$DDFactory.<init>(Ejb3HandlerFactory.java:25)
           at org.jboss.ejb3.Ejb3HandlerFactory.getInstance(Ejb3HandlerFactory.java:58)
           at org.jboss.ejb3.Ejb3Deployment.deploy(Ejb3Deployment.java:263)
           at org.jboss.ejb3.Ejb3Deployment.create(Ejb3Deployment.java:251)
           at org.jboss.ejb3.Ejb3JmxDeployment.create(Ejb3JmxDeployment.java:230)
           at org.jboss.ejb3.Ejb3Module.createService(Ejb3Module.java:34)
           at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:245)
           at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:228)
           at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
           at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:943)
           at $Proxy0.create(Unknown Source)
           at org.jboss.system.ServiceController.create(ServiceController.java:341)
           at org.jboss.system.ServiceController.create(ServiceController.java:284)
           at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
           at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
           at $Proxy10.create(Unknown Source)
           at org.jboss.ejb3.EJB3Deployer.create(EJB3Deployer.java:208)
           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:585)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
           at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
           at $Proxy11.create(Unknown Source)
           at org.jboss.deployment.MainDeployer.create(MainDeployer.java:935)
           at org.jboss.deployment.MainDeployer.create(MainDeployer.java:925)
           at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:789)
           at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:753)
           at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
           at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
           at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
           at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
           at $Proxy6.deploy(Unknown Source)
           at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:319)
           at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:507)
           at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:192)
           at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:265)
           at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:274)
           at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:230)
           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:585)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
           at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:943)
           at $Proxy0.start(Unknown Source)
           at org.jboss.system.ServiceController.start(ServiceController.java:428)
           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:585)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
           at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
           at $Proxy4.start(Unknown Source)
           at org.jboss.deployment.SARDeployer.start(SARDeployer.java:285)
           at org.jboss.deployment.MainDeployer.start(MainDeployer.java:989)
           at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:790)
           at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:753)
           at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:737)
           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:585)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
           at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
           at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
           at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
           at $Proxy5.deploy(Unknown Source)
           at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:453)
           at org.jboss.system.server.ServerImpl.start(ServerImpl.java:330)
           at org.jboss.Main.boot(Main.java:187)
           at org.jboss.Main$1.run(Main.java:438)
           at java.lang.Thread.run(Thread.java:595)
          Caused by: org.xml.sax.SAXException: Element type "message-driven" must be declared. @ *unknown*[6,23]
           at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$MetaDataErrorHandler.error(SaxJBossXBParser.java:232)
           at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
           at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
           at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
           at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
           at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
           at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
           at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
           at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
           at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
           at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
           at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
           at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
           at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
           at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:134)
           ... 114 more
          


          What do I do wrong? Am I on the rhight way? Or is there another way to bind the JCA Resource Adapter?

          Claus

          • 2. Re: How can I use EJB3/MDBs with the swiftmq-ivm.rar
            William DeCoste Apprentice

            I believe the problem is the usage of the ejb 2.0 DTDs. If you remove the DOCTYPE tag, the problem should be fixed. Once the 3.0 DTDs/Schemas are finalized, you can use those.

            • 3. Re: How can I use EJB3/MDBs with the swiftmq-ivm.rar
              William DeCoste Apprentice

              You need to add an additional AcivationConfigProperty for the resource adaptor. Here is an example. I will be posting a tutorial for this shortly.

              @ActivationConfigProperty(propertyName="resourceAdaptorName", propertyValue="swiftmq.rar")