<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Re: Using JNDI to connect to Websphere MQ, without hardcoded info
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/zecas">zecas zecas</a> in <i>JNDI and Naming</i> - <a href="http://community.jboss.org/message/631664#631664">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I have tried another solution that I believe will getting me closer to no dependencies on project code.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>As I said, I'm posting my findings here.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Instead of connecting to MQ Series using the resource adapter wmq.jmsra.rar, as described in this document:</p><p><em>Using WebSphere MQ Series with JBossAS Part IV - Integration using the IBM WebSphere JMS Resource Adapter&#160; (RECOMMENDED WAY!!)</em></p><p><span style="text-decoration: underline;"><a class="jive-link-wiki-small" href="http://community.jboss.org/docs/DOC-12535">http://community.jboss.org/docs/DOC-12535</a></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I followed the document:</p><p><em>Using WebSphere MQ Series with JBossAS Part III - Integration using an external context</em></p><p><a class="jive-link-wiki-small" href="http://community.jboss.org/docs/DOC-12534">http://community.jboss.org/docs/DOC-12534</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I have copied the following libs:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">Directory of C:\...\jboss-5.1.0.GA\server\default\lib 
30-03-2011&#160; 10:21&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 698.737 commonservices-2.3.jar 
30-03-2011&#160; 10:21&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 446.549 defaultconfig-2.3.jar 
30-03-2011&#160; 10:21&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 2.011.835 dhbcore-1.0.jar 
30-03-2011&#160; 10:21&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 356.293 headers-2.3.jar 
30-03-2011&#160; 10:21&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 1.904.071 jmqi-2.3.jar 
30-03-2011&#160; 10:21&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 438.016 mq-2.3.jar 
30-03-2011&#160; 10:21&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 17.657 mqcontext-2.3.jar 
30-03-2011&#160; 10:21&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 3.229.664 mqjms-1.1.jar 
30-03-2011&#160; 10:21&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 13.968 Nojndi-2.3.jar 
30-03-2011&#160; 10:21&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 103.980 pcf-1.4.2.jar 
30-03-2011&#160; 10:21&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 124.522 pcf-6.1-6.1.jar 
30-03-2011&#160; 10:21&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 7.758.362 postcard-2.3.jar 
30-03-2011&#160; 10:21&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 893.796 rmm-1.0.jar 
30-03-2011&#160; 10:21&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 101.628 soap-1.4.2.jar 
30-03-2011&#160; 10:21&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 31.996 tools.ras-1.4.2.jar
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>These dependencies were copied from my MQ Series java lib folder, the names are a bit different (with versions), maven style <span> :) </span>.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I created a provider definition for Websphere MQ in <em>C:\...\jboss-5.1.0.GA\server\default\conf\jboss-service.xml</em>:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span> 

<span class="jive-xml-comment"><span>&lt;!-- $Id: jboss-service.xml 88695 2009-05-12 03:32:03Z </span><a class="jive-link-email-small" href="mailto:bstansberry@jboss.com" target="_blank">bstansberry@jboss.com</a><span> $ --&gt; 

&lt;!-- ===================================================================== --&gt; 
&lt;!--&#160; JBoss Server Configuration&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; --&gt; 
&lt;!-- ===================================================================== --&gt; 

</span><span class="jive-xml-tag">&lt;server&gt;</span> 

&#160;&#160;&#160; &lt;!-- 
&#160;&#160;&#160; ... 
&#160;&#160;&#160; --&gt; 

&lt;!-- WebSphere MQ context JNDI --&gt;</span> 
<span class="jive-xml-tag">&lt;mbean code="org.jboss.naming.ExternalContext" 
name="DefaultDomain:service=ExternalContext,jndiName=wsmq"&gt;</span> 
<span class="jive-xml-tag">&lt;attribute name="JndiName"&gt;</span>wsmq<span class="jive-xml-tag">&lt;/attribute&gt;</span> 
<span class="jive-xml-tag">&lt;attribute name="Properties"&gt;</span> 
java.naming.factory.initial=com.ibm.mq.jms.context.WMQInitialContextFactory 
java.naming.provider.url=192.168.1.30:1414/SYSTEM.DEF.SVRCONN 
java.naming.security.authentication=none 
<span class="jive-xml-tag">&lt;/attribute&gt;</span> 
<span class="jive-xml-tag">&lt;attribute name="InitialContext"&gt;</span>javax.naming.InitialContext<span class="jive-xml-tag">&lt;/attribute&gt;</span> 
<span class="jive-xml-tag">&lt;/mbean&gt;</span> 

<span class="jive-xml-tag">&lt;/server&gt;</span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Then I defined my connection factories on <em>C:\...\jboss-5.1.0.GA\server\default\deploy\wsmq-ds.xml</em>:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="jive-xml-tag">&lt;connection-factories&gt;</span>
<span class="jive-xml-comment">&lt;!-- ==================================================================== --&gt;
&lt;!-- WSMQ connection factories --&gt;
&lt;!-- ==================================================================== --&gt;
&lt;!-- The WSMQ JMS provider loader --&gt;
<span class="jive-xml-tag">&lt;mbean code="org.jboss.jms.jndi.JMSProviderLoader"
name="jboss.mq:service=JMSProviderLoader,name=WSMQJMSProvider"&gt;</span>
<span class="jive-xml-tag">&lt;attribute name="ProviderName"&gt;</span>WSMQJMSProvider<span class="jive-xml-tag">&lt;/attribute&gt;</span>
<span class="jive-xml-tag">&lt;attribute name="ProviderAdapterClass"&gt;</span>org.jboss.jms.jndi.JNDIProviderAdapter<span class="jive-xml-tag">&lt;/attribute&gt;</span>
<span class="jive-xml-tag">&lt;attribute name="QueueFactoryRef"&gt;</span>wsmq/QM_server01<span class="jive-xml-tag">&lt;/attribute&gt;</span>
<span class="jive-xml-tag">&lt;attribute name="TopicFactoryRef"&gt;</span>wsmq/QM_server01<span class="jive-xml-tag">&lt;/attribute&gt;</span>
<span class="jive-xml-tag">&lt;/mbean&gt;</span>
&lt;!-- The WSMQ JMS connection factory --&gt;</span>
<span class="jive-xml-tag">&lt;no-tx-connection-factory&gt;</span>
<span class="jive-xml-tag">&lt;jndi-name&gt;</span>WSMQJms<span class="jive-xml-tag">&lt;/jndi-name&gt;</span>
<span class="jive-xml-tag">&lt;rar-name&gt;</span>jms-ra.rar<span class="jive-xml-tag">&lt;/rar-name&gt;</span>
<span class="jive-xml-tag">&lt;connection-definition&gt;</span>org.jboss.resource.adapter.jms.JmsConnectionFactory<span class="jive-xml-tag">&lt;/connection-definition&gt;</span>
<span class="jive-xml-tag">&lt;config-property name="SessionDefaultType" type="java.lang.String"&gt;</span>javax.jms.Topic<span class="jive-xml-tag">&lt;/config-property&gt;</span>
<span class="jive-xml-tag">&lt;config-property name="JmsProviderAdapterJNDI" type="java.lang.String"&gt;</span>java:/WSMQJMSProvider<span class="jive-xml-tag">&lt;/config-property&gt;</span>
<span class="jive-xml-tag">&lt;max-pool-size&gt;</span>20<span class="jive-xml-tag">&lt;/max-pool-size&gt;</span>
<span class="jive-xml-tag">&lt;/no-tx-connection-factory&gt;</span>
<span class="jive-xml-tag">&lt;/connection-factories&gt;</span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Last but not least, my Message Driven Bean:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">@MessageDriven( 
&#160;&#160;&#160;&#160;&#160;&#160;&#160; activationConfig = <font color="navy">{</font> 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; @ActivationConfigProperty(propertyName=<font color="red">"destinationType"</font>, propertyValue=<font color="red">"javax.jms.Queue"</font>), 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; @ActivationConfigProperty(propertyName=<font color="red">"destination"</font>, propertyValue=<font color="red">"wsmq/TestQ"</font>), 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; @ActivationConfigProperty(propertyName=<font color="red">"providerAdapterJNDI"</font>, propertyValue=<font color="red">"java:/WSMQJMSProvider"</font>) 
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>)
<font color="navy"><b>public</b></font> <font color="navy"><b>class</b></font> TestMQ <font color="navy"><b>implements</b></font> MessageListener <font color="navy">{</font>
&#160;
&#160;&#160;&#160; <font color="navy"><b>public</b></font> <font color="navy"><b>void</b></font> onMessage(Message message) <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println(message.toString());
&#160;&#160;&#160; <font color="navy">}</font>
&#160;
<font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>At this time, any message that falls into TestQ on MQ Series will be delivered to my Message Driven Bean.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I'm yet to try to send a message to the queue, that should use the "no-tx-connection-factory" defined in the "wsmq-ds.xml" file (correct me if I'm wrong), but at least, I have a startup point without many dependencies to JBoss nor MQ Series on my project.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The only dependency I have now is:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">@ActivationConfigProperty(propertyName=<font color="red">"providerAdapterJNDI"</font>, propertyValue=<font color="red">"java:/WSMQJMSProvider"</font>)
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Since I want to blindly deploy the project on a Websphere Application Server (latter on), I don't believe that property will go unnoticed there without some obscure deployment error :).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So I was trying to inject the annotation in JBoss only, and using AOP whould seem a good feature ... inject on JBoss side.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>For that, I tried deploying the aop on <em>C:\...\jboss-5.1.0.GA\server\default\deploy\wsmq-aop.xml</em>:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="jive-xml-tag">&lt;aop xmlns="urn:jboss:aop-beans:1.0"&gt;</span>
&#160;&#160;&#160; <span class="jive-xml-tag">&lt;domain name="TestQ" extends="Message Driven Bean" inheritBindings="true"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;annotation expr="!class(@org.jboss.ejb3.annotation.DefaultActivationSpecs)"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; @org.jboss.ejb3.annotation.DefaultActivationSpecs ({@javax.ejb.ActivationConfigProperty(propertyName = <span class="jive-xml-quote">providerAdapterJNDI</span>, propertyValue = <span class="jive-xml-quote">java:/WSMQJMSProvider</span>)})
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/annotation&gt;</span>
&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/domain&gt;</span>

<span class="jive-xml-tag">&lt;/aop&gt;</span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>And after removing the refered annotation, I'm not able to deliver messages to my MDB.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So at this time, I need some opinions on this subject, any tip on what can I do to inject that annotation with JBoss AOP features (or something else on JBoss side). How am I supposed to inject that annotation?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>(At the same time, I'm trying to create an alternative bridge between my local JBoss queues and remote MQ Series queues. That can give me some more knowledge about JBoss features and may help save the day, latter on ... in this project or on any future one)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Any help is welcomed.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/631664#631664">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JNDI and Naming at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>