首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法为spring-jms设置正确的maven依赖项

无法为spring-jms设置正确的maven依赖项
EN

Stack Overflow用户
提问于 2013-06-19 00:17:44
回答 1查看 6.7K关注 0票数 1

我有一个涉及spring-mvc/jms/active-mq的项目。在Eclipse Juno中尝试部署到Tomcat 7.26时出现以下异常:

代码语言:javascript
复制
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

代码语言:javascript
复制
<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>

spring配置的相关部分:

代码语言:javascript
复制
<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,那么我就开始为其他的spring-jms工具如MessageConverter获取ClassNotFoundException了。

我想可能是wtp插件出了问题,但是,从命令行运行:

代码语言:javascript
复制
mvn clean package

结果如下:

代码语言:javascript
复制
package org.springframework.jms.support.converter does not exist

我可以验证包是否存在于.m2中,以及spring-jms-3.2.3.RELEASE.jar是否包含上述包。

ActiveMQ作为独立服务器运行,我可以登录http:localhost:8161/admin

此配置中缺少什么?任何帮助都将不胜感激。谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-06-19 01:05:38

您可能在类路径上有其他一些Spring jar版本(可能在某个tomcat共享类加载器中)。将-verbose添加到CATALINA_OPTS,以查看从哪些jar加载的类。

编辑

另外,请看一下eclipse POM编辑器中的依赖关系图--您可能必须排除由其他项目传递引入的Spring deps。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17173975

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档