title: How to do jndi lookup of MQ connection factory defined in Websphere app Server from Spring
body: <p>I am trying to connect to a MQ connection factory defined in Websphere app Server 7.0.</p>
  
  <p>But I couldnt find a right connectionfactory interface for the MQ to define in Spring.</p>
  
  <p>However when I tried to hardcode the connection details in the spring config file, I am able to connect to the Queue Manager.</p>
  
  <p>What is the right interface/format to use in Spring beans to load the MQ connection factory defined in Websphere appl server?</p>
  
  <p><strong>Working Code</strong></p>
  
  <pre><code>&lt;bean id="mqConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory"&gt;
      &lt;property name="hostName"&gt;
          &lt;value&gt;127.0.0.1&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="port"&gt;
          &lt;value&gt;1414&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="queueManager"&gt;
          &lt;value&gt;MYQM&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="transportType"&gt;
          &lt;value&gt;1&lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p><strong>Not Working Code</strong></p>
  
  <pre><code>&lt;bean id="mqConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
      &lt;property name="jndiName" value="jms/WASQM"/&gt;
      &lt;property name="lookupOnStartup" value="false"/&gt;
      &lt;property name="cache" value="true" /&gt;
      &lt;property name="proxyInterface"  value="com.ibm.mq.jms.MQQueueConnectionFactoryFactory" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>where WASQM is the MQ connection factory defined in Websphere</p>
  
  <p><strong>Error with the Non working code</strong></p>
  
  <pre><code> org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mqConnectionFactory' defined in ServletContext resource [/WEB-INF/config/config-mq.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: [com.ibm.mq.jms.MQQueueConnectionFactoryFactory] is not an interface
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
  Caused by: java.lang.IllegalArgumentException: [com.ibm.mq.jms.MQQueueConnectionFactoryFactory] is not an interface
  </code></pre>
  
  <p>I need help in replacing the not working code with a right code.
  Spring - 3.0.5
  IBM MQ and Web App Servers - 7.0</p>