我有一个涉及 spring-mvc/jms/active-mq 的项目。尝试在 Eclipse Juno 中部署到 Tomcat 7.26 时出现以下异常:
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.jms.connection.CachingConnectionFactory] for bean with name 'cachingConnectionFactory' defined in ServletContext resource [/WEB-INF/authmgr-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.jms.connection.CachingConnectionFactory
Caused by: java.lang.ClassNotFoundException: org.springframework.jms.connection.CachingConnectionFactory
pom.xml
<project>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.springframework.version>3.2.3.RELEASE</org.springframework.version>
<org.springframework.security.version>3.1.3.RELEASE</org.springframework.security.version>
<hibernate.version>4.1.9.Final</hibernate.version>
<org.apache.tiles.version>2.2.2</org.apache.tiles.version>
</properties>
<repositories>
<repository>
<id>repository.springsource.release</id>
<name>SpringSource Repository</name>
<url>http://repo.springsource.org/release</url>
</repository>
<repository>
<id>repository.jboss.org-public</id>
<name>JBoss.org Maven repository</name>
<url>https://repository.jboss.org/nexus/content/groups/public</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-mail</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>${org.springframework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.8.0</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-spring</artifactId>
<version>3.13</version>
</dependency>
</dependencies>
弹簧配置的相关部分:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:util="http://www.springframework.org/schema/util"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:task="http://www.springframework.org/schema/task" xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms.xsd
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/oxm/spring-oxm.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core.xsd">
<!-- JMS -->
<amq:connectionFactory id="connectionFactory"
brokerURL="tcp://localhost:61616" />
<bean id="cachingConnectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory" ref="connectionFactory" />
<property name="sessionCacheSize" value="100" />
</bean>
<!-- Integration with Focus -->
<amq:queue id="appointmentsImportQ" physicalName="FOCUS.APPOINTMENTS.EXPORT.QUEUE" />
<bean id="appointmentsImportMessageListener"
class="com.test.authmgr.service.messaging.AppointmentsImportMessageListener">
</bean>
<bean id="appointmentsImportMsgListenerContainer"
class="org.springframework.jms.listener.SimpleMessageListenerContainer">
<property name="connectionFactory" ref="cachingConnectionFactory" />
<property name="destination" ref="appointmentsImportQ" />
<property name="messageListener" ref="appointmentsImportMessageListener" />
<property name="concurrentConsumers" value="1" />
</bean>
<bean id="oxmAppointmentsImportMessageConverter"
class="org.springframework.jms.support.converter.MarshallingMessageConverter">
<property name="marshaller" ref="appointmentsImportMarshaller" />
<property name="unmarshaller" ref="appointmentsImportMarshaller" />
</bean>
<oxm:jaxb2-marshaller id="appointmentsImportMarshaller">
<oxm:class-to-be-bound
name="com.test.authmgr.focus.integration.jaxb.Profile" />
</oxm:jaxb2-marshaller>
</beans>
如果 spring-framework 的版本降低到 3.1.x,那么我开始获取ClassNotFoundException
其他 spring-jms 的东西,比如MessageConverter
.
我认为 wtp 插件可能有问题,但是,从命令行运行:
mvn clean package
结果是:
package org.springframework.jms.support.converter does not exist
我可以验证该包确实存在.m2
并且spring-jms-3.2.3.RELEASE.jar
确实包含所述包。
ActiveMQ
作为独立服务器运行,我可以登录http:localhost:8161/admin
。
此配置缺少什么?任何帮助将不胜感激。谢谢。