13 Replies Latest reply on Sep 13, 2012 5:27 PM by Paulo Merson

    Can't deploy MDB on JBoss AS 7.1 to consume from standalone HornetQ

    Paulo Merson Newbie

      I (too) am having trouble deploying an MDB on JBoss AS 7.1 that will consume from a queue in a remote standalone HornetQ.

       

      My test scenario (using only my Windows 7 desktop for now):

      1) Open a command prompt and launch standalone HornetQ 2.2.14.final with QueueX configured.

      2) A Java main client sends messages to QueueX.

      3) On a separate command prompt, launch JBoss AS 7.1.0.final using standalone.xml.  HornetQ is *not* integrated in this JBoss instance. 

      4) Deploy hornetq-ra.rar on jboss-as-7.1.0.Final\standalone\deployments. File ra.xml  inside hornetq-ra.rar  is configured to connect to HornetQ on localhost:

      {code:xml}

            <config-property>

               <description>

                  The transport type. Multiple connectors can be configured by using a comma separated list,

                  i.e. org.hornetq.core.remoting.impl.invm.InVMConnectorFactory,org.hornetq.core.remoting.impl.invm.InVMConnectorFactory.

               </description>

      <config-property-name>ConnectorClassName</config-property-name>

               <config-property-type>java.lang.String</config-property-type>

      <config-property-value>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</config-property-value>

            </config-property>

            <config-property>

               <description>The transport configuration. These values must be in the form of key=val;key=val;,

                  if multiple connectors are used then each set must be separated by a comma i.e. host=host1;port=5445,host=host2;port=5446.

                  Each set of params maps to the connector classname specified.

               </description>

      <config-property-name>ConnectionParameters</config-property-name>

      <config-property-type>java.lang.String</config-property-type>

      <config-property-value>host=127.0.0.1;port=5445</config-property-value>

            </config-property>

      {code}

       

       

      5) Deploy a single MDB that consumes messages from QueueX. Activation properties:

      {code}

      @MessageDriven(

              activationConfig = {

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

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

      @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),

                      @ActivationConfigProperty(propertyName = "connectorClassName", propertyValue = "org.hornetq.core.remoting.impl.netty.NettyConnectorFactory"),

      @ActivationConfigProperty(propertyName = "connectionParameters", propertyValue = "host=localhost;port=5445")

              })

      @ResourceAdapter("/hornetq-ra.rar")

      {code}

       

      All the steps up to #5 work fine. The resource adapter is deployed successfully:

      14:20:19,247 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "hornetq-ra.rar"

       

      But the deployment of my EAR containing a single MDB fails with this cryptic error message:

      JBAS014775:    New missing/unsatisfied dependencies:

      service jboss.ra.hornetq-ra (missing) dependents: [service jboss.deployment.subunit."monitoramentoEar.ear"."monitoramentoEjb.jar".component.MdbLoggerBD.CREATE]

       

      17:01:14,875 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.deployment.subunit.\"monitoramentoEar.ear\".\"monitoramentoEjb.jar\

      ".component.MdbLoggerBD.CREATEjboss.ra.hornetq-raMissing[jboss.deployment.subunit.\"monitoramentoEar.ear\".\"monitoramentoEjb.jar\".component.MdbLoggerBD.CREATEjboss.ra.hornetq-ra]"]}}}

       

      Following the MDB deployment failure, if I stop the JBoss server, an intriguing message appears on the console:

      JBAS014776:    Newly corrected services:

            service jboss.ra.hornetq-ra (new available)

       

      Any help to solve this problem is greatly appreciated.

       

      Things I tried and didn’t solve the problem:

      1) Using standalone-full on JBoss.

      2) Removing  the @ResourceAdapter("/hornetq-ra.rar") annotation from the MDB.

      3) Copying file jms-remote-ds.xml to the deployments directory. (Deployment failed with a parse error message. A forum search showed me this file is not valid in AS 7.)

       

      Things I didn’t try yet:

      1) Deploying hornetq-ra.rar inside the ear. No documentation indicates this is the solution, and it poses a connector configuration challenge when I have multiple ear files.

      2) Define a JMS connection factory or pooled connection factory in my JBoss configuration. Didn’t see clear instructions pointing in that direction for my scenario (no HornetQ integrated to JBoss).

      3) Debugging AS 7 deployer code.

      4) Cursing at the screen (female coworkers nearby).

      5) Lighting a candle (smoke detector right above).

       

      Links I studied, helped me move forward, but didn’t present a working solution for my scenario:

        • 2. Re: Can't deploy MDB on JBoss AS 7.1 to consume from standalone HornetQ
          Andy Taylor Master

          I tried deploying it in this fashion but came across the same issues, I think there are quite a few dependencies that need deploying as well, either that or there is a jca bug. I will speak to the AS7 guys and see if there are any issues.

           

          However i did manage to get this working by using a pooled connection factory, downside here tho is you need to deploy a hornetq server in the AS which isnt used, i just slimmed this right down so it isnt really too much of an issue, so here's what I did.

           

          1.     configured a standalone HornetQ server to use port 5446, added the queue and started it.

          2.     added a new socket binding for this in the standalone-full.xml:

           

                  <socket-binding name="remote-messaging" port="5446"/>

           

          3. slimmed down the HornetQ config like so:

           

          <subsystem xmlns="urn:jboss:domain:messaging:1.3">

                      <hornetq-server>

                          <persistence-enabled>false</persistence-enabled>

           

                          <connectors>

                              <netty-connector name="netty-remote" socket-binding="remote-messaging"/>

                          </connectors>

           

                          <jms-connection-factories>

                              <pooled-connection-factory name="hornetq-ra">

                                  <transaction mode="xa"/>

                                  <connectors>

                                      <connector-ref connector-name="netty-remote"/>

                                  </connectors>

                                  <entries>

                                      <entry name="java:/JmsXA"/>

                                  </entries>

                              </pooled-connection-factory>

                          </jms-connection-factories>

              </hornetq-server>

          </subsystem>

           

          4.     deployed and tested the MDB

           

          I think this is the simplest approach to take, let me know how it goes

          • 3. Re: Can't deploy MDB on JBoss AS 7.1 to consume from standalone HornetQ
            Clebert Suconic Master

            How to specify a pooled connection factory on my MDB? say if I had two?

             

            Is there anything that is currently done for that on the integration?

            • 4. Re: Can't deploy MDB on JBoss AS 7.1 to consume from standalone HornetQ
              Andy Taylor Master

              How to specify a pooled connection factory on my MDB? say if I had two?

              You just override any activation properties you need too

              • 5. Re: Can't deploy MDB on JBoss AS 7.1 to consume from standalone HornetQ
                Clebert Suconic Master

                /me thinking as an user...

                 

                 

                Since the inbound is specified by a pooled connection factory, it would be nice if we could somehow specify what pooled connection factory to copy properties from. We could still specify activation properties if we wanted.. etc.. but I think it would be easier that way.

                 

                WDYT?

                • 6. Re: Can't deploy MDB on JBoss AS 7.1 to consume from standalone HornetQ
                  Andy Taylor Master

                  thats still done via the name so on the pooled connection factory

                   

                  <pooled-connection-factory name="hornetq-remote-ra">

                   

                  and on the mdb

                   

                  @ResourceAdapter("/hornetq-remote-ra.rar")

                  • 7. Re: Can't deploy MDB on JBoss AS 7.1 to consume from standalone HornetQ
                    Clebert Suconic Master

                    Ok, so then Paulo can just keep the local hornetq, deploy a secondary pooled connection factory and specify @ResourceAdapter("/pooled-connection-factory-name.rar")

                    • 8. Re: Can't deploy MDB on JBoss AS 7.1 to consume from standalone HornetQ
                      Andy Taylor Master

                      correct, or if he doesnt need the local horneq slim it down like i suggested

                      • 9. Re: Can't deploy MDB on JBoss AS 7.1 to consume from standalone HornetQ
                        Paulo Merson Newbie

                        I made significant progress, but the proposed solution didn’t work yet.

                        Here’s what I did:

                        • On HornetQ side, changed config\stand-alone\non-clustered\hornetq-configuration.xml  to use port 5446 instead of port 5445. That is:
                          • changed parameter “port” under connector “netty”.
                          • changed parameter “port” under acceptor “netty”.
                        • On AS 7 side, edited standalone-full.xml to reflect Andy’s solution:
                          • added the remote-messaging socked binding to the socket-binding-group section.
                          • replaced the original messaging subsystem definition with the new one that defines the slimmed down integrated hornetq-server.
                        • Changed my AS 7 launch configuration to use standalone-full.xml.
                        • Edited ra.xml that goes inside hornetq-ra.rar.
                          • Changed the following for config property  “ConnectionParameters”:

                        {code:xml}

                        <config-property-value>host=127.0.0.1;port=5446</config-property-value>

                        {code}

                        • Started HornetQ on command prompt window.
                        • Cleaned the AS 7 deployments directory.
                        • Tried to started AS 7 on a separate window, but it failed to parse the messaging subsystem declaration:

                        Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[220,9]

                        Message: Unexpected element '{urn:jboss:domain:messaging:1.3}subsystem'

                        • A quick diff hinted me the namespace for my AS 7.1.0.Final should be 1.1. So I changed that line to:

                        {code:xml}

                                <subsystem xmlns="urn:jboss:domain:messaging:1.1">

                        {code}

                         

                        • Started AS 7 with integrated HornetQ  successfully:

                        11:04:41,027 INFO [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) HornetQ Server version 2.2.11.Final (HQ_2_2_11_FINAL_AS7, 122) [7b8c0ee6-e7ec-11e1-af41-d027885e1eb2]) started

                        11:04:41,043 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]

                        11:04:41,059 WARN [jacorb.codeset] (MSC service thread 1-7) Warning - unknown codeset (Cp1252) - defaulting to ISO-8859-1

                        11:04:41,074 INFO [org.jboss.as.jacorb] (MSC service thread 1-7) JBAS016330: CORBA ORB Service started

                        11:04:41,121 INFO [org.jboss.as.jacorb] (MSC service thread 1-6) JBAS016328: CORBA Naming Service started

                        11:04:41,168 INFO [org.jboss.as.deployment.connector] (MSC service thread 1-4) JBAS010406: Registered connection factory java:/JmsXA

                        11:04:41,168 INFO [org.hornetq.ra.HornetQResourceAdapter] (MSC service thread 1-4) HornetQ resource adaptor started

                        11:04:41,183 INFO  [org.jboss.as.connector.services.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-4) IJ020002: Deployed: file://RaActivatorhornetq-ra

                        11:04:41,183 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-6) JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]

                         

                        • Then I deployed hornetq-ra.rar with my edited ra.xml to the deployments directory. It failed:

                        Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.ra.deployer.hornetq-ra is already registered

                         

                        • So I tried the obvious: use a different name for the resource adapter…
                        • Renamed the deployment rar to myhornetq-ra.rar.
                        • Edited the @ResourceAdapter annotation in the MDB:

                        {code}

                        @ResourceAdapter("myhornetq-ra.rar")

                        {code}

                         

                        • Edited the pooled connection factory name in standalone-full.xml:

                        {code:xml}

                        <pooled-connection-factory name="myhornetq-ra">

                        {code}

                         

                        • Cleaned the deployments directory and started AS 7 again. Success:

                        11:20:23,473 INFO [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-4) HornetQ Server version 2.2.11.Final (HQ_2_2_11_FINAL_AS7, 122) [7b8c0ee6-e7ec-11e1-af41-d027885e1eb2]) started

                        11:20:23,489 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]

                        11:20:23,536 INFO [org.jboss.as.jacorb] (MSC service thread 1-6) JBAS016328: CORBA Naming Service started

                        11:20:23,629 INFO [org.jboss.as.deployment.connector] (MSC service thread 1-4) JBAS010406: Registered connection factory java:/JmsXA

                        11:20:23,629 INFO [org.hornetq.ra.HornetQResourceAdapter] (MSC service thread 1-4) HornetQ resource adaptor started

                        11:20:23,629 INFO [org.jboss.as.connector.services.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-4) IJ020002: Deployed: file://RaActivatormyhornetq-ra

                        11:20:23,629 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-6) JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]

                         

                        • Then I deployed myhornetq-ra.rar to the deployments directory. It failed like the first time:

                        Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.ra.deployer.myhornetq-ra is already registered

                         

                        QUESTION: do I need to deploy the rar file that contains ra.xml configured as I described in my original post?  If I do, how do I overcome this duplicate registration issue?

                        • 10. Re: Can't deploy MDB on JBoss AS 7.1 to consume from standalone HornetQ
                          Paulo Merson Newbie

                          Following up...

                          • I removed the rar file from the deployments directory and deployed my ear file.
                          • To my great surprise it worked right away!     The MDB got all the messages that were in the queue.

                           

                          I think anyone trying to make this work will stumble into the rar configuration as a separate deployment versus inside the ear versus from within standalone-full.xml.

                          I hope this thread and future documentation updates will clear the waters.

                           

                          I also hope the rar deployment to AS 7 without HornetQ gets fixed. My organization has EAP and we're migrating to EAP 6 soon. (That's the reason I'm playing with AS 7 on my local machine.).  So, in production we don't want to have HornetQ running on every server that has an MDB. For now apparently these servers will require integrated HornetQ with the slimmed down configuration.

                          • 11. Re: Can't deploy MDB on JBoss AS 7.1 to consume from standalone HornetQ
                            Clebert Suconic Master

                            @Andy: What could we do to improve this? I don't recall of examples distributed with AS7 for HornetQ? I looked for how to specify the @ResourceAdapter on the pooled connection factory and I couldn't find the info, but I was too busy with this support case I'm doing now to RTFM . Maybe the info was there and I missed it? it's worth taking a look and improve this.

                             

                            @Paulo: Can you open a JIRA to fix the remote-deploy without HornetQ installed? that should be an issue on AS7 component with HOrnetQ as the component. (If you can't open a JIRA for any reason let us know and we will do it).

                            • 12. Re: Can't deploy MDB on JBoss AS 7.1 to consume from standalone HornetQ
                              Paulo Merson Newbie

                              Clebert, Andy, I created issue AS7-5483.

                               

                              The workaround proposed by Andy worked for me. However, after I deployed a war file on the server where the MDB is deployed, upon startup the pooled connection factory simply disappeared from standalone-full.xml!  Apparently AS 7 does that in some situations.  Please see the last three messages in this thread.

                               

                              Andy, any ideas to make the pooled factory unsusceptible to this AS 7 automatic rewrite?

                              • 13. Re: Can't deploy MDB on JBoss AS 7.1 to consume from standalone HornetQ
                                Paulo Merson Newbie

                                Because of a bug in the standalone-full.xml validation, you need to add a dummy <connection-factory>. So, the messaging subsystem declaration should look like this:

                                 

                                <subsystem xmlns="urn:jboss:domain:messaging:1.1">

                                <hornetq-server>

                                    <persistence-enabled>false</persistence-enabled>

                                    <connectors>

                                        <netty-connector name="netty-remote" socket-binding="remote-messaging"/>

                                    </connectors>

                                    <jms-connection-factories>

                                        <connection-factory name="dummyCF">

                                            <connectors>

                                                <connector-ref connector-name="netty-remote"/>

                                            </connectors>

                                            <entries>

                                                <entry name="java:jboss/exported/jms/dummyCF"/>

                                            </entries>

                                        </connection-factory>

                                        <pooled-connection-factory name="myhornetq-ra">

                                            <transaction mode="xa"/>

                                            <connectors>

                                                <connector-ref connector-name="netty-remote"/>

                                            </connectors>

                                            <entries>

                                                <entry name="java:/JmsXA"/>

                                            </entries>

                                        </pooled-connection-factory>

                                    </jms-connection-factories>

                                </hornetq-server>

                                </subsystem>