First issue: when deploying the resource adapter as it is, the deployer raises the following error:
org.jboss.jca.validator.ValidatorException: Severity: ERROR
Section: 19.4.2
Description: A ResourceAdapter must implement a "public int hashCode()" method.
Code: com.sun.messaging.jms.ra.ResourceAdapter

Severity: ERROR
Section: 19.4.2
Description: A ResourceAdapter must implement a "public boolean equals(Object)" method.
Code: com.sun.messaging.jms.ra.ResourceAdapter

So obviously our RA doesn't seem 100% compliant. There are two things you can do, one is implementing the two methods by yourself in the com.sun.messaging.jms.ra.ResourceAdapter class, or turn off validation on the JBoss JCA subsystem. We will choose the latter so turn off archive validation in your AS 7 configuration:

<subsystem xmlns="urn:jboss:domain:jca:1.1">
  <archive-validation enabled="false" fail-on-error="true" fail-on-warn="false"/>
  . . . .
</subsystem>

Second issue: the second issue we faced was a bit harder, as a matter of fact there was a NPE when the resource adapter was initialized:

13:34:15,054 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC00001: Failed to start service jboss.ra.deployer.imqjmsra: org.jboss.msc.service.StartException in service jboss.ra.deployer.imqjmsra: JBAS010446: Failed to start RA deployment [imqjmsra]
        at org.jboss.as.connector.services.resourceadapters.deployment.ResourceAdapterDeploymentService.start(ResourceAdapterDeploymentService.java:105)
        . . . . .
Caused by: org.jboss.jca.deployers.common.DeployException: IJ020052: Unable to associate com.sun.messaging.jms.ra.ActivationSpec
        at org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer.associateResourceAdapter(AbstractResourceAdapterDeployer.java:386)
        ... 10 more
Caused by: java.lang.NullPointerException
        at com.sun.messaging.jms.ra.ResourceAdapter._getRAUID(ResourceAdapter.java:2081)
        at com.sun.messaging.jms.ra.ActivationSpec.setResourceAdapter(ActivationSpec.java:331)

The problem is buried into the _getRAUID method which fails to return the Resource Adapter Id. The only viable choice is getting our hands dirty with the source code. This is the part of the code we are dealing with:
protected String _getRAUID() {

        if (raUID==null && !_isRADirect()){
            try {

                XAConnectionImpl xaci = (com.sun.messaging.jmq.jmsclient.XAConnectionImpl) xacf.createXAConnection();
                raUID = Long.toString(xaci.generateUID());
                xaci.close();
            } catch (JMSException jmse){
                _loggerB.severe("Unable to generate UID:"+jmse.getMessage());
            }
        }

        return null;
    }

What happens here is that a lazy initialization of the XAConnection is performed. As per ActivationSpec we should initialize our resources into the start method of our Resource Adapter, so change this method to:
protected String _getRAUID() {


        if (  !_isRADirect()){
            return raUID;
        }

        return null;
    }

and add the XA Connection creation at the end of the start method:
    public synchronized void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
       . . ..
      try {
                XAConnectionImpl xaci = (com.sun.messaging.jmq.jmsclient.XAConnectionImpl) xacf.createXAConnection();
                raUID = Long.toString(xaci.generateUID());


                xaci.close();
            } catch (JMSException jmse){
                _loggerB.severe("Unable to generate UID:"+jmse.getMessage());
            }


    }

It was necessary to compile the new class (just add all the OpenMQ libraries in your classpath) and update the archive in the modules section:

jar uvf com imqjmsra.jar	

(The class ResourceAdapter.java is contained in the package com.sun.messaging.jms.ra)
Great, we're almost there. The last cry of the application server is about a duplicate resource java:jboss/eis/QueueConnection

07:09:21,668 ERROR [org.jboss.msc.service] (MSC service thread 1-5) MSC00002: Invocation of listener "org.jboss.as.connector.deployers.ra.processors.ParsedRaDeploymentProcessor$1@1e7a6ae" failed: java.lang.IllegalStateException: JBAS014666:
 Duplicate resource java:jboss/eis/QueueConnection

Recall the file ironjacamar.xml ? careful readers should have noticed that it actually contains a duplication for the resource resource java:jboss/eis/QueueConnection . However that's not the fault of the rarinfo tool, it's the ra.xml file (which ships with the RA) that contains the duplication (the rarinfo creates the sample RA connection from the ra.xml file)

So this is the final ironjacamar.xml file which needs to be deployed in META-INF:

<?xml version="1.0" encoding="UTF-8"?>

<ironjacamar>

    <config-property name="UserName">guest</config-property>
    <config-property name="ConnectionURL">mq://localhost:7676/</config-property>
    <config-property name="Password">guest</config-property>
    <transaction-support>XATransaction</transaction-support>
    <connection-definitions>
      <connection-definition class-name="com.sun.messaging.jms.ra.ManagedConnectionFactory" enabled="true" jndi-name="java:jboss/eis/QueueConnection" pool-name="QueueConnection" use-ccm="true" use-java-context="true">
        <config-property name="UserName">guest</config-property>
        <config-property name="AddressList">localhost</config-property>
        <config-property name="Password">guest</config-property>
        <xa-pool>
          <min-pool-size>0</min-pool-size>
          <max-pool-size>10</max-pool-size>
          <prefill>false</prefill>
          <use-strict-min>false</use-strict-min>
          <flush-strategy>FailingConnectionOnly</flush-strategy>
          <pad-xid>false</pad-xid>
          <wrap-xa-resource>true</wrap-xa-resource>
        </xa-pool>
        <security>
          <application/>
        </security>
      </connection-definition>
      
      <connection-definition class-name="com.sun.messaging.jms.ra.ManagedConnectionFactory" enabled="true" jndi-name="java:jboss/eis/TopicConnection" pool-name="TopicConnection" use-ccm="true" use-java-context="true">
        <config-property name="UserName">guest</config-property>
        <config-property name="AddressList">localhost</config-property>
        <config-property name="Password">guest</config-property>
        <xa-pool>
          <min-pool-size>0</min-pool-size>
          <max-pool-size>10</max-pool-size>
          <prefill>false</prefill>
          <use-strict-min>false</use-strict-min>
          <flush-strategy>FailingConnectionOnly</flush-strategy>
          <pad-xid>false</pad-xid>
          <wrap-xa-resource>true</wrap-xa-resource>
        </xa-pool>
        <security>
          <application/>
        </security>
      </connection-definition>
    </connection-definitions>
    <admin-objects>
      <admin-object class-name="com.sun.messaging.Queue" enabled="true" jndi-name="java:jboss/eis/ao/Queue" pool-name="Queue" use-java-context="true">

      </admin-object>
      <admin-object class-name="com.sun.messaging.Topic" enabled="true" jndi-name="java:jboss/eis/ao/Topic" pool-name="Topic" use-java-context="true">

      </admin-object>
    </admin-objects>
 
</ironjacamar>

Great, now we're finally ready. You need to start your Glassfish server where OpenMQ lives.

glassfish/bin/startserv.sh

Fine, now start JBoss AS 7 (hint: in order to avoid conflicts with glassfish, if you are running both on the same Pc, apply a port-offset to your configuration)


    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="200">

 On your JBoss AS 7 console you should now see:
 
 13:04:31,862 INFO [org.jboss.as.deployment.connector] (MSC service thread 1-3)
JBAS010401: Bound JCA ConnectionFactory [java:jboss/eis/TopicConnection]
13:04:31,863 INFO [org.jboss.as.deployment.connector] (MSC service thread 1-2)
JBAS010401: Bound JCA AdminObject [java:jboss/eis/ao/Topic]
13:04:31,864 INFO [org.jboss.as.deployment.connector] (MSC service thread 1-5)
JBAS010401: Bound JCA AdminObject [java:jboss/eis/ao/Queue]
13:04:31,863 INFO [org.jboss.as.deployment.connector] (MSC service thread 1-4)
JBAS010401: Bound JCA ConnectionFactory [java:jboss/eis/QueueConnection]

Great! now let's test everything:

0
0
0
s2smodern