4 Replies Latest reply on Dec 14, 2007 4:01 AM by François Duchatelet

    Setting up a non-server specific EAR

    Juan Bustamante Newbie

      I am currently working on a project that uses an MDB to read messages off of an MQ queue, process them, and then write the response to another queue on the same queue manager.

      The issue that we are having is that we have server specific data such as the hostname, queue name to drain from etc. within our ejb-jar.xml. This is a hastle for our build team because they require a new EAR file for each JBoss server they deploy the application on. My question is the following. Is there a way to separate the server specific data from the ejb-jar.xml?

      The technologies that we use are IBM Websphere MQ Explorer with fixpack 6.0.2, JBoss AS 4.0.5.GA, java 1.5_011.

      The following is a sample EJB definition from our ejb-jar.xml.


      <message-driven>
       <ejb-name>Listener1</ejb-name>
       <ejb-class>qualified class name</ejb-class>
       <messaging-type>javax.jms.MessageListener</messaging-type>
       <transaction-type>Container</transaction-type>
       <env-entry>
       <env-entry-name>EJBName</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value>Listener1</env-entry-value>
       </env-entry>
       <env-entry>
       <!-- The JNDI name of the connection factory used -->
       <!-- to send the response. -->
       <env-entry-name>connectionFactory</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value>java:WSMQueueConnectionFactory</env-entry-value>
       </env-entry>
       <env-entry>
       <!-- The JNDI location of the queue used -->
       <!-- to send the response. -->
       <env-entry-name>queueJndi</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value>java:queue</env-entry-value>
       </env-entry>
       <activation-config>
       <activation-config-property>
       <activation-config-property-name>destination</activation-config-property-name>
       <activation-config-property-value>QUEUE.NAME</activation-config-property-value>
       </activation-config-property>
       <activation-config-property>
       <activation-config-property-name>destinationType</activation-config-property-name>
       <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
       </activation-config-property>
       <activation-config-property>
       <activation-config-property-name>useJNDI</activation-config-property-name>
       <activation-config-property-value>false</activation-config-property-value>
       </activation-config-property>
       <activation-config-property>
       <activation-config-property-name>hostName</activation-config-property-name>
       <activation-config-property-value>ourHost</activation-config-property-value>
       </activation-config-property>
       <activation-config-property>
       <activation-config-property-name>queueManager</activation-config-property-name>
       <activation-config-property-value>ourQM</activation-config-property-value>
       </activation-config-property>
       <activation-config-property>
       <activation-config-property-name>transportType</activation-config-property-name>
       <activation-config-property-value>CLIENT</activation-config-property-value>
       </activation-config-property>
       <activation-config-property>
       <activation-config-property-name>port</activation-config-property-name>
       <activation-config-property-value>1414</activation-config-property-value>
       </activation-config-property>
       </activation-config>
       </message-driven>


      We followed the WIKI site about how to set up JBoss with WS MQ part 4.

      Thank you very much in advance,

      Juan

        • 1. Re: Setting up a non-server specific EAR
          Elias Ross Master

          This is really a "IBM Websphere MQ" question, since those activation properties come from that application.

          There are a couple ways to solve this. One you can use Java system property, e.g. mq.host, and define this using -D, and then have the XML text be ${mq.host} for the host name property. This is probably the easiest. The other is to extend the inflow adapter class:
          http://www.jboss.org/wiki/Wiki.jsp?page=ConfigJMSMessageListener

          See: JBossJMSMessageEndpointFactory.augmentActivationConfigProperties


          • 2. Re: Setting up a non-server specific EAR
            Juan Bustamante Newbie

            I was thinking that if we set the useJNDI property to "true", it would look within the application server's JNDI namespace and retrieve the object based on the JNDI name that we provide within the Destination value.

            <activation-config-property>
             <activation-config-property-name>destination</activation-config-property-name>
             <activation-config-property-value>JNDI NAME</activation-config-property-value>
             </activation-config-property>
             <activation-config-property>
             <activation-config-property-name>destinationType</activation-config-property-name>
             <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
             </activation-config-property>
             <activation-config-property>
             <activation-config-property-name>useJNDI</activation-config-property-name>
             <activation-config-property-value>true</activation-config-property-value>
             </activation-config-property>



            So I defined an Admin Object for the inbound queue, and I was thinking that by setting the useJNDI to be true, the application server would look up the admin object within the server's JNDI namespace as it would for the outbound queue, but instead I get the following error.

            javax.resource.spi.ResourceAdapterInternalException: javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'localhost:'
             at com.ibm.mq.connector.ResourceAdapterConnectionPool.allocateConnection(ResourceAdapterConnectionPool.java:297)
             at com.ibm.mq.connector.ResourceAdapterImpl.endpointActivation(ResourceAdapterImpl.java:333)
             at org.jboss.resource.deployment.RARDeployment.endpointActivation(RARDeployment.java:271)
             at org.jboss.resource.deployment.RARDeployment.internalInvoke(RARDeployment.java:226)
             at org.jboss.system.ServiceDynamicMBeanSupport.invoke(ServiceDynamicMBeanSupport.java:156)
             at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.ejb.plugins.inflow.JBossMessageEndpointFactory.activate(JBossMessageEndpointFactory.java:484)
             ... 113 more
            Caused by: javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'localhost:'
             at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:614)
             at com.ibm.mq.jms.MQConnection.createQM(MQConnection.java:2480)
             at com.ibm.mq.jms.MQConnection.createQMNonXA(MQConnection.java:1830)
             at com.ibm.mq.jms.MQConnection.<init>(MQConnection.java:811)
             at com.ibm.mq.jms.MQConnectionFactory.createConnection(MQConnectionFactory.java:4821)
             at com.ibm.mq.connector.ResourceAdapterConnectionPool.initializeJMSConnection(ResourceAdapterConnectionPool.java:445)
             at com.ibm.mq.connector.ResourceAdapterConnectionPool.createNewConnection(ResourceAdapterConnectionPool.java:359)
             at com.ibm.mq.connector.ResourceAdapterConnectionPool.allocateConnection(ResourceAdapterConnectionPool.java:284)
             ... 120 more


            • 3. Re: Setting up a non-server specific EAR
              François Duchatelet Newbie

              With useJNDI=true and the following AdminObject defined, it works.

              <!-- admin object definition -->



              queue/TEST

              <depends optional-attribute-name="RARName">
              jboss.jca:service=RARDeployment,name='wmq.jmsra.rar'

              javax.jms.Queue


              baseQueueManagerName=MWTEST
              baseQueueName=TEST



              Cheers,

              • 4. Re: Setting up a non-server specific EAR
                François Duchatelet Newbie

                Oups, I forgot the code blocks :-(

                 <!-- admin object definition -->
                 <mbean code="org.jboss.resource.deployment.AdminObject"
                 name="wsmq:service=Destination,name=tst-q1">
                
                 <attribute name="JNDIName">
                 queue/TEST
                 </attribute>
                 <depends optional-attribute-name="RARName">
                 jboss.jca:service=RARDeployment,name='wmq.jmsra.rar'
                 </depends>
                 <attribute name="Type">javax.jms.Queue</attribute>
                
                 <attribute name="Properties">
                 baseQueueManagerName=MWTEST
                 baseQueueName=TEST
                 </attribute>
                 </mbean>