Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating Spring Boot 2.7.0 to 3.0.2, Am facing issue ( jakarta.jms.ConnectionFactory cannot be typecast to com.ibm.mq.jms.MQConnectionFactory)

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.jms.core.JmsTemplate]: Factory method 'jmsTemplate' threw exception with message: class com.ibm.mq.jms.MQConnectionFactory cannot be cast to class jakarta.jms.ConnectionFactory (com.ibm.mq.jms.MQConnectionFactory and jakarta.jms.ConnectionFactory are in unnamed module of loader 'app')
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:171)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
    ... 66 common frames omitted
Caused by: java.lang.ClassCastException: class com.ibm.mq.jms.MQConnectionFactory cannot be cast to class jakarta.jms.ConnectionFactory (com.ibm.mq.jms.MQConnectionFactory and jakarta.jms.ConnectionFactory are in unnamed module of loader 'app')

Issue might be because of IBM MQ is not supporting higher version or not compatible with spring 6 but not sure. looking for the resolution for the issue.

like image 369
Sudhir Ahirkar Avatar asked Oct 29 '25 19:10

Sudhir Ahirkar


1 Answers

MQ provides Jakarta-compatible packages. You have to change your dependencies to use the correct module.

If you're using the MQ Spring Boot library, then use the corresponding V3.x.x artifact.

If you are directly referencing the MQ client libraries, then use com.ibm.mq.jakarta.client instead of the com.ibm.mq.allclient.

like image 159
Mark Taylor Avatar answered Oct 31 '25 09:10

Mark Taylor