Alex Rivera | Logout

Upgrading from Spring 3.0.3.RELEASE results in: java.lang.NoSuchFieldError: USER_DECLARED_METHODS

Asked 2010-11-22T09:57:15.033
9

I have a Spring-MVC 3.0 web application built with Maven. All Spring dependency versions are defined with a maven property <spring.version>3.0.3.RELEASE</spring.version>. When I change the version to either 3.0.4.RELEASE or 3.0.5.RELEASE, then the web application fails with the following exception:

ERROR: [DispatcherServlet] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is java.lang.NoSuchFieldError: USER_DECLARED_METHODS
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
        at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
        at org.sp
Edit
Report

2 Answers

13

It turned out two of our own dependencies both had dependencies on Spring 3.0.0.RELEASE. Adding an exclusion to each of these as:

<exclusions>
    <exclusion>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
    </exclusion>
</exclusions>

fixed the problem.

This smells like a Spring bug to me as I did not see this problem using 3.0.1, 3.0.2 or 3.0.3.

answered 2010-11-23T02:54:47.757
0

In response to your last comment, you can use the 'dependencyManagement' section of the POM to try to mitigate the Spring 3.0.0 requirement of your internal dependencies. This should force everything to use Spring 3.0.5.RELEASE if you place the proper 'dependency' elements under your dependencyManagement section.

answered 2010-11-23T00:49:11.730

Your Answer