2013-06-18 3 views
1

У меня есть проект с участием spring-mvc/jms/active-mq. Получение следующее исключение при попытке развернуть на Tomcat 7.26 в Eclipse, Juno:Невозможно установить правильную зависимость maven для spring-jms

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> 

Если версия весеннего каркаса понижена, чтобы сказать 3.1.x, тогда я начинаю получать ClassNotFoundException для других весенних предметов вроде MessageConverter.

Я думал, может быть что-то не так с ВОС плагин, однако, запуск из командной строки:

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.

Что отсутствует в этой конфигурации? Любая помощь будет оценена. Спасибо.

ответ

0

Возможно, у вас есть еще одна версия Spring jar на пути к классам (возможно, в одном из разделяемых загрузчиков классов tomcat). Добавьте -verbose в CATALINA_OPTS, чтобы узнать, какие классы jar (s) загружаются из.

EDIT

Также обратите внимание на график зависимости в редакторе POM затмение - вы, возможно, придется исключить Spring DEPS принес в транзитивно других проектах.

+0

Я попробую, но это не объяснит ошибку из командной строки: mvn clean package. – kmansoor

+0

Посмотрите на иерархию зависимостей в редакторе POM eclipse. –

+0

Я нашел проблему. Если бы тестировали весну-jms. Слепой вырезать и вставить. Принимая ваш ответ, поскольку он поставил меня на правильный путь. – kmansoor

Смежные вопросы