2012-02-06 113 views
1

所以基本上我收到一個異常,當我加載我的玻璃魚應用服務器的戰爭。我正在使用Spring的事務管理器和我的mysql數據庫。報告的錯誤(完整的堆棧跟蹤)如下:春季交易管理器(註釋樣式)運行時錯誤

java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.getAnnotation(Ljava/lang/reflect/AnnotatedElement;Ljava/lang/Class;)Ljava/lang/annotation/Annotation; 

我applicationContext.xml文件如下:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:sws="http://www.springframework.org/schema/web-services" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:oxm="http://www.springframework.org/schema/oxm" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd 
    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
    http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd"> 

    <context:property-placeholder location="classpath:testjdbc.properties"/> 

    <!-- enable the configuration of transactional behavior based on annotations --> 
    <tx:annotation-driven transaction-manager="txManager"/> 

     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> 
     <property name="driverClassName" value="${jdbc.driverClassName}" /> 
     <property name="url" value="${jdbc.url}" /> 
     <property name="username" value="${jdbc.username}" /> 
     <property name="passwprd" value="${jdbc.password}" /> 
     </bean> 

     <bean name="licenseGenService" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"> 
     <property name="service" ref="LicensingDaoImpl"/> 
     <property name="serviceInterface" value="mypackage.LicensingDao"/> 
     </bean> 

     <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 
     <property name ="dataSource" ref="dataSource" /> 
     </bean> 

     <bean id="licenseDAO" class = "myPackage.LicenseDao"> 
     <constructor-arg ref="dataSource" /> 
     </bean> 

     <bean id="licenseGenerator" class ="myPackage.LicenseGeneratorImpl"> 
     <constructor-arg ref = "licenseDAO" /> 
     </bean> 

</beans> 

我發現這個錯誤是相當神祕的,因爲它是發牢騷類甚至沒有在我的應用程序上下文中。順便說一句,我正在使用Spring 3.1。感謝您的任何建議或幫助。

+0

相關問題/解決方案:http://stackoverflow.com/questions/9496413/java-lang-nosuchmethoderror-org-springframework-core-annotation-annotationutils – 2012-09-27 11:35:01

回答

5

看看你的類路徑,並確保只有一個版本的所有你的Spring依賴關係。

+0

大師和指揮官! – thatidiotguy 2012-02-06 17:06:44

+0

查看下面Tomasz的答案,即:確保所有Spring JAR都使用相同的版本! – 2012-09-27 11:34:00

+0

我只有版本的Spring依賴關係(3.2.2),但仍然得到相同的錯誤。我正嘗試將我的項目從硬連接的jar文件配置遷移到基於maven的配置。 – 2013-05-01 23:55:00

4

顯然你的應用程序正在使用老版本的spring-core*.jar。確保所有Spring JAR文件都在3.1.x版本中,並且沒有重複項。

spring-core*.jar包含在3.1中引入的AnnotationUtils.getAnnotation()方法。

+0

感謝您的回答! – thatidiotguy 2012-02-06 17:17:31