2
votes

i wrote a WS-Application in Spring which support to create Messages into a JMS Queue. I developed it using an Apache Tomcat with ActiveMQ. Everthing works fine here, I have my JNDI resource can derive the Connection factory and send the message into the queue:

<jee:jndi-lookup id="jndiJmsQueueConnectionFactory"
        jndi-name="${jms.factory.jndiName}" proxy-interface="javax.jms.ConnectionFactory"
        lookup-on-startup="false">
 </jee:jndi-lookup>

<jee:jndi-lookup id="jndiSendQueue" jndi-name="${jms.myQueue.jndiName}"
        proxy-interface="javax.jms.Queue" lookup-on-startup="false"></jee:jndi-lookup>

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref ="jmsQueueConnectionFactory"></property>
        <property name="sessionAcknowledgeModeName" value="AUTO_ACKNOWLEDGE"/>

</bean>

Now we tried to move the web-application to the Websphere. The JNDI lookup works, the application can create the Factory, the Queue is found, but when my Code tries to create the producer via createProducer() the code throws this exception:

java.lang.ClassCastException: com.sun.proxy.$Proxy28 cannot be cast to com.ibm.mq.jms.MQDestination

I tried to replace "javax.jms.Queue" with "javax.jms.Destination" but not worked.

when I remove proxy-interface it is working but I need that queue not to fetched when context is launching.

1

1 Answers

2
votes

When using Spring it wraps the looked up Destination in a Spring dynamic proxy. The WebSphere MQ JMS provider requires an implementation of its Destination and it doesn't receive one hence the exception. You might be able to get round this calling toString on the looked up destination and then calling createDestination with the result on the Session object.