spring整合activeMQ遇到异常:Error creating bean with name 'connectionFactory'

异常详情

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectionFactory': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.jms.connection.SingleConnectionFactory] from ClassLoader [ParallelWebappClassLoader

context: ROOT
delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@31206beb
]

 

Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.jms.connection.SingleConnectionFactory] from ClassLoader [ParallelWebappClassLoader
context: ROOT
delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@31206beb
]

 

Caused by: java.lang.ClassNotFoundException: javax.jms.JMSContext

 

分析

创建connectionFactory失败 → 创建SingleConnectionFactory失败 → 找不到JMSContext类

配置文件中,创建的是CachingConnectionFactory,它是SingleConnectionFactory的子类,而SingleConnectionFactory类中用到了一个叫JMSContext的类,现在最根本的原因就在于找不到这个类。既然以前同样的配置没问题,现在这样的配置找不到某个类,首先怀疑的就是版本问题。果然,以前的项目中用的spring4,那时候的SingleConnectionFactory并不需要JMSContext;而现在用的spring5,添加了关于这个类的返回值。JMSContext类属于javax.jms包,原来用的是1.1版本,更新成2版的即可:

原文地址:https://www.cnblogs.com/dubhlinn/p/11243548.html