运行 Java 8 来自 WebSphere 8 的 MQ 应用程序出错

Error while running Java 8 MQ application from WebSphere 8

我在尝试从 WebSphere 8 运行 Java 8 MQ 应用程序时遇到以下错误:

java.lang.IllegalStateException: Cannot convert value of type 'com.ibm.ejs.jms.JMSQueueConnectionFactoryHandle' to required type 'javax.jms.ConnectionFactory"

经过一些研究,我在这里看到了一些建议,可以通过删除所有 javax.jms jar 来解决上述错误。我的 war 文件中有 jms-api-2.0 和 geronimo-jms_1.1_spec 罐子。我删除了它们,之后我看到以下错误:

java.lang.NoClassDefFoundError: javax.jms.JMSRuntimeException

这将需要 JMS jar。请指教

Jars 打包在我的 war:

spring-boot-starter-web:jar:1.5.17.RELEASE
spring-boot-starter:jar:1.5.17.RELEASE
spring-boot-starter-log4j2:jar:1.5.17.RELEASE
spring-boot-starter-activemq:jar:1.5.17.RELEASE
commons-lang3:jar:3.5
cxf-rt-frontend-jaxws:jar:3.1.11
cxf-rt-transports-http:jar:3.1.11
cxf-rt-ws-security:jar:3.1.11
wss4j-ws-security-common:jar:2.2.1
groovy:jar:2.4.11
gson:jar:2.8.5
spring-boot-configuration-processor:jar:1.5.17.RELEASE
com.ibm.mq:jar:8.0.0.5
com.ibm.mq.headers:jar:8.0.0.5
com.ibm.mq.pcf:jar:8.0.0.5
com.ibm.mqjms:jar:8.0.0.5
com.ibm.mq.connector:jar:7.5.0.5
dhbcore:jar:7.5.0.5
mqcontext:jar:2.3
com.ibm.mq.commonservices:jar:8.0.0.5
jaxb-impl:jar:2.2.11
jaxb-core:jar:2.2.11
spring-oxm:jar:4.3.20.RELEASE

删除所有 com.ibm 罐子并添加 com.ibm.mq.allclient 和 jms 罐子后,我的 war 文件中的新罐子列表:

spring-boot-starter-web:jar:1.5.17.RELEASE
spring-boot-starter:jar:1.5.17.RELEASE
spring-boot-starter-log4j2:jar:1.5.17.RELEASE
spring-boot-starter-activemq:jar:1.5.17.RELEASE
commons-lang3:jar:3.5
cxf-rt-frontend-jaxws:jar:3.1.11
cxf-rt-transports-http:jar:3.1.11
cxf-rt-ws-security:jar:3.1.11
wss4j-ws-security-common:jar:2.2.1
groovy:jar:2.4.11
gson:jar:2.8.5
spring-boot-configuration-processor:jar:1.5.17.RELEASE
jaxb-impl:jar:2.2.11
jaxb-core:jar:2.2.11
spring-oxm:jar:4.3.20.RELEASE
javax.jms-api:jar:2.0
com.ibm.mq.allclient:jar:9.1.1.0

我认为您缺少 IBM MQ "jms.jar" 文件。另外,您为什么使用 IBM MQ v8.0.0.5?它已经过时了。

与其乱搞许多 MQ JAR 文件,不如使用 "com.ibm.mq.allclient" 和 "jms.jar" JAR 文件。

前往 Maven 并使用 and/or 下载 IBM MQ v9.1.3.0 and then also download the jms.jar

WAS 8.5.5.x not support JMS 2.0:

WebSphere® Application Server supports applications that use JMS 1.1 domain-independent interfaces (referred to as "common interfaces" in the JMS specification) and JMS 1.0.2 domain-specific interfaces.

您应该使用 WAS 内置 IBM MQ resource adapter 而不是随 WAR 一起交付 MQ 库。

配置 Queue Connection Factory in the WAS console and follow the WAS/Spring 准则以引用此连接工厂。