Wednesday, May 27, 2009

How to fix Spring and MQ issue of Failed to convert property value of type [javax.naming.Reference] to required type [javax.jms.ConnectionFactory]

I ran into this exception and had to waste some hours to fix it. I was using Rational Application Developer 6 with Websphere MQ 5.3 to run a command line client. It should be valid for even higher versions of RAD and WMQ.

Exception is

org.springframework.beans.TypeMismatchException: Failed to convert property value of type [javax.naming.Reference] to required type [javax.jms.ConnectionFactory] for property 'targetConnectionFactory';

I hope that following will help others who run into this issue.

Steps you can take to solve this are:

1) Make sure that you have following jars in classpath:

* com.ibm.mq.jar
* com.ibm.mqbind.jar
* com.ibm.mqjms.jar
* ecutils.jar
* j2ee.jar
* messaging.jar
* messagingClient.jar
* messagingImpl.jar
* namingclient.jar

2) If above is there in classpath but you are still getting this error then check if you have conflicting version of jms related classes.

Sometimes, we have 2 different versions of jms.jar or jms related classes.

Make sure that you have right version of classes.

3) If you suspect class loading issue then use -verbose as a vm argument to see the classloading details.

See following article for RAD and JMS for more details.

1 comment:

Unknown said...

I was facing same issue even after updating the ClassLoading settings. Finally I removed the 'activemq-all.jar' from my applicaiton's '.war' file and then this worked for me.