1

So essentially I am getting a exception when I load up my war in my glassfish application server. I am using Spring's transaction manager with my mysql database. The error reported (full stack trace) is as follows:

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;

My applicationContext.xml file is as follows:

<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>

I find this error to be pretty cryptic because the class it is whining about is not even in my application Context. I am using Spring 3.1 by the way. Thanks for any suggestions or help.

Adriano
  • 19,463
  • 19
  • 103
  • 140
thatidiotguy
  • 8,701
  • 13
  • 60
  • 105
  • related question/solution: http://stackoverflow.com/questions/9496413/java-lang-nosuchmethoderror-org-springframework-core-annotation-annotationutils – Adriano Sep 27 '12 at 11:35

2 Answers2

5

Look in your classpath and make sure there's only one version of all your Spring dependencies there.

Johan Sjöberg
  • 47,929
  • 21
  • 130
  • 148
  • Check out Tomasz's answer below too, that is: Make sure all Spring JARs are using the same version as well! – Adriano Sep 27 '12 at 11:34
  • I have only version of Spring dependencies (3.2.2) but still getting the same error. I am trying to migrate my project from a hard wired jar file configuration to a maven based configuration. – Rohit Banga May 01 '13 at 23:55
  • Fixed it ... I think by mistake I had included an older version of Spring in Maven but had changed it back to the latest one. I had updated sources, project, restarted server, shutdown eclipse and restarted but I got this error. I removed the Server configuration from eclipse and added a new configuration. It worked this time. – Rohit Banga May 02 '13 at 16:51
4

Apparently your application is using older version of spring-core*.jar. Make sure all Spring JARs are in 3.1.x version and you have no duplicates.

spring-core*.jar contains the AnnotationUtils.getAnnotation() method introduced in 3.1.

Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674