2013-07-31 39 views
1

我想從spring 3.0.7升級項目到spring 3.2.3。我目前被困在activemq依賴關係的問題上,無法弄清楚我需要的是什麼jar或者在第一個地方發生衝突。下面是我的堆棧跟蹤春天3.2.3:activemq 5.5依賴關係問題

org.unitils.core.UnitilsException: Unable to create application context for locations [classpath:producerServiceContext-test.xml] at org.unitils.spring.util.ApplicationContextManager.createInstanceForValues(ApplicationContextManager.java:121) at org.unitils.spring.util.ApplicationContextManager.createInstanceForValues(ApplicationContextManager.java:36) at org.unitils.core.util.AnnotatedInstanceManager.getInstanceImpl(AnnotatedInstanceManager.java:234) at org.unitils.core.util.AnnotatedInstanceManager.getInstance(AnnotatedInstanceManager.java:121) at org.unitils.spring.util.ApplicationContextManager.getApplicationContext(ApplicationContextManager.java:65) at org.unitils.spring.SpringModule.getApplicationContext(SpringModule.java:235) at org.unitils.spring.SpringModule$1.isApplicableFor(SpringModule.java:108) at org.unitils.database.transaction.impl.DefaultUnitilsTransactionManager.getTransactionManagementConfiguration(DefaultUnitilsTransactionManager.java:180) at org.unitils.database.transaction.impl.DefaultUnitilsTransactionManager.startTransaction(DefaultUnitilsTransactionManager.java:96) at org.unitils.database.DatabaseModule.startTransaction(DatabaseModule.java:410) at org.unitils.database.DatabaseModule.startTransactionForTestMethod(DatabaseModule.java:381) at org.unitils.database.DatabaseModule$DatabaseTestListener.beforeTestSetUp(DatabaseModule.java:535) at org.unitils.core.Unitils$UnitilsTestListener.beforeTestSetUp(Unitils.java:273) at org.unitils.UnitilsJUnit4TestClassRunner$TestListenerInvokingMethodRoadie.runBeforesThenTestThenAfters(UnitilsJUnit4TestClassRunner.java:151) at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:84) at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49) at org.unitils.UnitilsJUnit4TestClassRunner.invokeTestMethod(UnitilsJUnit4TestClassRunner.java:95) at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:61) at org.unitils.UnitilsJUnit4TestClassRunner.access$000(UnitilsJUnit4TestClassRunner.java:44) at org.unitils.UnitilsJUnit4TestClassRunner$1.run(UnitilsJUnit4TestClassRunner.java:62) at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34) at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44) at org.unitils.UnitilsJUnit4TestClassRunner.run(UnitilsJUnit4TestClassRunner.java:68) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in class path resource [producerServiceContext-test.xml]: Initialization of bean failed; nested exception is java.lang.NoSuchFieldError: NULL at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) at org.unitils.spring.util.ApplicationContextManager.createInstanceForValues(ApplicationContextManager.java:117) ... 28 more Caused by: java.lang.NoSuchFieldError: NULL at org.springframework.expression.TypedValue.(TypedValue.java:32) at org.springframework.expression.spel.support.StandardEvaluationContext.setRootObject(StandardEvaluationContext.java:88) at org.springframework.expression.spel.support.StandardEvaluationContext.(StandardEvaluationContext.java:74) at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:124) at org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1312) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.evaluate(BeanDefinitionValueResolver.java:225) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:201) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ... 37 more

以下是我的ActiveMQ POM依賴

<dependency> 
     <groupId>org.apache.activemq</groupId> 
     <artifactId>activemq-core</artifactId> 
     <version>5.5.0</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.activemq</groupId> 
     <artifactId>activemq-pool</artifactId> 
     <version>5.5.0</version> 
    </dependency> 

而且我使用的彈簧3.2.3的發佈包。我喜歡避免粘貼這個文件,因爲它有一些相關性,我寧願保持這個簡潔和重點。

這是我的ApplicationContext如果有人在同樣的集成問題我真的很感激一些反饋來了,是不會加載

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
    http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> 

    <!-- lets create an embedded ActiveMQ Broker --> 
    <amq:broker useJmx="false" persistent="false"> 
     <amq:transportConnectors> 
      <amq:transportConnector uri="tcp://localhost:0" /> 
     </amq:transportConnectors> 
    </amq:broker> 

    <!-- ActiveMQ destinations to use --> 
    <amq:queue id="destination" physicalName="org.apache.activemq.spring.Test.spring.embedded" /> 

    <!-- JMS ConnectionFactory to use, configuring the embedded broker using XML --> 
    <amq:connectionFactory id="jmsFactory" brokerURL="vm://localhost?broker.persistent=false" /> 


    <!-- Spring JMS Template --> 
    <bean id="fastJmsTemplate" class="org.springframework.jms.core.JmsTemplate"> 
     <property name="connectionFactory"> 
      <!-- lets wrap in a pool to avoid creating a connection per send --> 
      <bean class="org.springframework.jms.connection.SingleConnectionFactory"> 
       <property name="targetConnectionFactory"> 
        <ref local="jmsFactory" /> 
       </property> 
      </bean> 
     </property> 
    </bean> 

    <bean id="consumerJmsTemplate" class="org.springframework.jms.core.JmsTemplate"> 
     <property name="connectionFactory" ref="jmsFactory" /> 
    </bean> 

    <bean id="fastJmsProducer" class="com.emakina.truvo.ssls.fast.service.util.FastJmsProducer"> 
     <property name="template"> 
      <ref bean="fastJmsTemplate"></ref> 
     </property> 

     <property name="destination"> 
      <ref bean="destination" /> 
     </property> 
    </bean> 

    <bean id="consumer" class="com.emakina.truvo.ssls.fast.service.util.SimpleFastJmsConsumer"> 
     <property name="template" ref="consumerJmsTemplate" /> 
     <property name="destination" ref="destination" /> 
    </bean> 

</beans> 

回答

2

我發現了導致問題的依賴關係。 Spring安全仍然在管理它的舊版本。

 <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-expression</artifactId> 
      <version>${org.springframework.version}</version> 
     </dependency> 

Spring-Security似乎在引入spring-expression 3.0.7。這導致activemq啓動它的代理的問題,因爲它使用該lib中的類。我通過在NoSuchField異常上放置一個斷點來發現問題,並查看它停止的類以及該類所屬的庫。我希望這也能幫助其他人。

在我的情況下,我只需要添加新的春天版本的依賴。