Results 1 to 6 of 6

Thread: Spring JMS with IBM MQ in tomcat

  1. #1

    Default Spring JMS with IBM MQ in tomcat

    Hi,

    After doing some research this is what i have found, here is my config:-

    server.xml:-

    <Context path="/some-server" docBase="some-server" debug="5"
    reloadable="true" crossContext="true" antiJARLocking="true">

    <!-- JMS SUPPORT FOR MQSeries - The connection factory -->
    <Resource
    name="jms/MQConnectionFactory"
    auth="Container"
    type="com.ibm.mq.jms.MQQueueConnectionFactory"
    factory="com.ibm.mq.jms.MQQueueConnectionFactoryFa ctory"
    description="JMS Queue Connection Factory for sending messages"
    HOST=<host>
    PORT=<port>
    CHAN=<channel>
    TRAN="1"
    QMGR=<queue manager> />

    <!-- JMS SUPPORT FOR MQSeries - the queue to send to -->
    <Resource
    name="jms/MQReader"
    auth="Container"
    type="com.ibm.mq.jms.MQQueue"
    factory="com.ibm.mq.jms.MQQueueFactory"
    description="JMS Queue for sending messages"
    QU=<queue> />

    <!-- JMS SUPPORT FOR MQSeries - the queue to read from -->
    <Resource
    name="jms/MQWriter"
    auth="Container"
    type="com.ibm.mq.jms.MQQueue"
    factory="com.ibm.mq.jms.MQQueueFactory"
    description="JMS Queue for receiving messages"
    QU=<queue> />

    </Context>

    applicationContext.xml:-

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:jms="http://www.springframework.org/schema/jms"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-2.5.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schem...ontext-2.5.xsd
    http://www.springframework.org/schema/jms http://www.springframework.org/schem...ng-jms-2.5.xsd
    http://www.springframework.org/schema/jee http://www.springframework.org/schem...ng-jee-2.5.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    <!-- ************************************************** ************ -->
    <!-- JMS queue setting to talk to JNDI defined MQSeries connections -->
    <!-- ************************************************** ************ -->

    <!-- Wrap the jndi connectionFactory in a Spring JndiObject -->
    <bean id="internalJMSQueueConnectionFactory"
    class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName">
    <value>java:comp/env/jms/MQConnectionFactory</value>
    </property>
    </bean>

    <!-- Wrap the connectionFactory in order to be able to add security on creation time -->
    <bean id="jmsQueueConnectionFactorySecured"
    class="org.springframework.jms.connection.UserCred entialsConnectionFactoryAdapter">
    <property name="targetConnectionFactory" ref="internalJMSQueueConnectionFactory" />
    <property name="username" value="******" />
    <property name="password" value="******" />
    </bean>

    <!-- Reading -->
    <!-- Rip the destination right out of JNDI -->
    <jee:jndi-lookup id="jmsDestinationResolverReader" jndi-name="java:comp/env/jms/MQReader" resource-ref="true" />
    <!-- JMS Queue Template -->
    <bean id="jmsReader" class="org.springframework.jms.core.JmsTemplate102 ">
    <!-- Factory creating the connections -->
    <property name="connectionFactory">
    <ref bean="jmsQueueConnectionFactorySecured" />
    </property>
    <!-- Use defaultDestination in order to be able to use JNDI directly -->
    <property name="defaultDestination">
    <ref bean="jmsDestinationResolverReader" />
    </property>
    <!-- We are accessing queue: so false -->
    <property name="pubSubDomain">
    <value>false</value>
    </property>
    <!-- Wait a meaningFull time for response -->
    <property name="receiveTimeout">
    <value>60000</value>
    </property>
    </bean>

    <!-- Writing -->
    <!-- Rip the destination right out of JNDI -->
    <jee:jndi-lookup id="jmsDestinationResolverWriter" jndi-name="java:comp/env/jms/MQWriter" resource-ref="true" />
    <!-- JMS Queue Template -->
    <bean id="jmsWriter" class="org.springframework.jms.core.JmsTemplate102 ">
    <!-- Factory creating the connections -->
    <property name="connectionFactory">
    <ref bean="jmsQueueConnectionFactorySecured" />
    </property>
    <!-- Use defaultDestination in order to be able to use JNDI directly -->
    <property name="defaultDestination">
    <ref bean="jmsDestinationResolverWriter" />
    </property>
    <!-- We are accessing queue: so false -->
    <property name="pubSubDomain">
    <value>false</value>
    </property>
    <!-- Wait a meaningFull time for response -->
    <property name="receiveTimeout">
    <value>60000</value>
    </property>
    </bean>

    <!-- ************************************************** ************ -->
    <!-- Beans injected with JMSQueueing -->
    <!-- ************************************************** ************ -->

    <!-- Bean used for sending messages -->
    <bean id="rvaSender" class="somepackage.Sender">
    <property name="jmsTemplate102">
    <ref bean="jmsWriter" />
    </property>
    </bean>

    <!-- Bean used for receiving messages -->
    <bean id="rvaReceiver" class="somepackage.Receiver">
    <property name="jmsTemplate102">
    <ref bean="jmsReader" />
    </property>
    </bean>

    </beans>

    Once the applicationContext.xml is loaded i am getting a "TypeMisMatchException" , here is the log for that:-

    SEVERE: Servlet threw load() exception
    org.springframework.beans.PropertyBatchUpdateExcep tion; nested PropertyAccessException details (2) are:
    PropertyAccessException 1:
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.ibm.mq.jms.MQQueueConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.ibm.mq.jms.MQQueueConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
    Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [com.ibm.mq.jms.MQQueueConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
    at org.springframework.beans.TypeConverterDelegate.co nvertIfNecessary(TypeConverterDelegate.java:231)

    I am using Spring 2 with Tomcat 6, where i am going wrong? whether this is due to some JAR been missed? or there any problem with applicationContext.xml doctype? Please do respond.

    Thanks in advance

  2. #2
    Join Date
    Aug 2010
    Posts
    11

    Default

    Im having the same problem.. Did you find a solution to this?

  3. #3
    Join Date
    Feb 2006
    Location
    Los Angeles, CA
    Posts
    79

    Default

    Does MQQueueConnectionFactory implement javax.jms.ConnectionFactory? That error looks like it's trying to do the equivalent of a cast and it can't. Another problem is you might have two diffrent javax.jms.ConnectionFactory classes on the CLASSPATH. HTH
    Josh Long
    Spring Developer Advocate
    SpringSource, a division of VMware

    http://blog.SpringSource.org
    http://www.joshlong.com

  4. #4
    Join Date
    Aug 2010
    Posts
    11

    Default

    thanks for your reply.. I eventually solved it, I was going to post my solution earlier but I couldn't find the post again..

    So to solve it I needed the websphere jars in my web app and in tomcat/lib. If I only have the websphere jars in tomcat then I would get that above error.

  5. #5

    Post Same Error ! Help with jars that are specific to WebSphere

    Hi ,

    I'm facing the same problem can you specify the websphere jars that u used to resolve the problem.

    Thanks in Advance !

  6. #6

    Default

    Hi ,

    I'm facing the same problem can you specify the websphere jars that u used to resolve the problem.

    Thanks in Advance !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •