当前位置:  开发笔记 > 编程语言 > 正文

从Spring 3.0.3.RELEASE升级导致:java.lang.NoSuchFieldError:USER_DECLARED_METHODS

如何解决《从Spring3.0.3.RELEASE升级导致:java.lang.NoSuchFieldError:USER_DECLARED_METHODS》经验,为你挑选了1个好方法。

我有一个使用Maven构建的Spring-MVC 3.0 Web应用程序.所有Spring依赖版本都使用maven属性定义3.0.3.RELEASE.当我将版本更改为3.0.4.RELEASE或者3.0.5.RELEASE,然后Web应用程序失败,并出现以下异常:

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.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
        at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
        at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
        at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
        at javax.servlet.GenericServlet.init(GenericServlet.java:241)
        at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:433)
        at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:256)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
        at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:612)
        at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
        at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220)
        at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:510)
        at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
        at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:110)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
        at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
        at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
        at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
        at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
        at org.mortbay.jetty.Server.doStart(Server.java:222)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
        at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
        at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:371)
        at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:307)
        at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:203)
        at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:314)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:151)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:445)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:168)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:132)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

我在Google http://forum.springsource.org/showthread.php?p=328767上找到了一个相关内容,但它没有帮助我,因为我已经在我的pom中检查了我的Spring版本并完成了许多干净的构建该项目.我正在运行webapp mvn jetty:run.

[编辑]以下是michael-lange要求的依赖树...

[INFO] au.org.ala:bie-admin:war:1.0-SNAPSHOT
[INFO] +- au.org.ala:bie-hbase:jar:1.0-SNAPSHOT:compile
[INFO] |  +- org.gbif:ecat-common:jar:1.1-SNAPSHOT:compile
[INFO] |  +- org.gbif:dwc-archive:jar:1.2-SNAPSHOT:compile
[INFO] |  |  +- com.trustice:tar:jar:2.5:compile
[INFO] |  |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  +- jaxen:jaxen:jar:1.1-beta-6:compile
[INFO] |  |  |  +- xerces:xmlParserAPIs:jar:2.6.2:compile
[INFO] |  |  |  \- xom:xom:jar:1.0b3:compile
[INFO] |  |  |     +- com.ibm.icu:icu4j:jar:2.6.1:compile
[INFO] |  |  |     \- org.ccil.cowan.tagsoup:tagsoup:jar:0.9.7:compile
[INFO] |  |  +- com.google.guava:guava:jar:r03:compile
[INFO] |  |  +- org.apache.commons:commons-compress:jar:1.0:compile
[INFO] |  |  \- com.google.inject:guice:jar:2.0:compile
[INFO] |  |     \- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  +- org.apache.hadoop:hbase:jar:0.20.4:compile
[INFO] |  +- org.apache.hadoop:zookeeper:jar:3.2.2:compile
[INFO] |  +- org.apache.hadoop:hadoop-core:jar:0.20.2:compile
[INFO] |  +- org.apache.hadoop:hadoop-ant:jar:0.20.2:compile
[INFO] |  +- org.apache.hadoop:hadoop-tools:jar:0.20.2:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.5.2:compile
[INFO] |  +- org.slf4j:slf4j-log4j12:jar:1.4.3:compile
[INFO] |  +- commons-cli:commons-cli:jar:1.2:compile
[INFO] |  +- org.apache.lucene:lucene-core:jar:2.9.2:compile
[INFO] |  +- org.apache.solr:solr-core:jar:1.4.0:compile
[INFO] |  |  +- org.apache.lucene:lucene-analyzers:jar:2.9.1:compile
[INFO] |  |  +- org.apache.lucene:lucene-highlighter:jar:2.9.1:compile
[INFO] |  |  +- org.apache.lucene:lucene-queries:jar:2.9.1:compile
[INFO] |  |  +- org.apache.lucene:lucene-snowball:jar:2.9.1:compile
[INFO] |  |  +- org.apache.lucene:lucene-memory:jar:2.9.1:compile
[INFO] |  |  +- org.apache.lucene:lucene-misc:jar:2.9.1:compile
[INFO] |  |  +- org.apache.lucene:lucene-spellchecker:jar:2.9.1:compile
[INFO] |  |  +- org.apache.solr:solr-commons-csv:jar:1.4.0:compile
[INFO] |  |  +- woodstox:wstx-asl:jar:3.2.7:compile
[INFO] |  |  \- org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1:compile
[INFO] |  +- org.apache.solr:solr-solrj:jar:1.4.0:compile
[INFO] |  |  \- org.codehaus.woodstox:wstx-asl:jar:3.2.7:compile
[INFO] |  |     \- stax:stax-api:jar:1.0.1:compile
[INFO] |  +- org.apache.cassandra:apache-cassandra:jar:0.6.1:compile
[INFO] |  +- org.apache.thrift:thrift:jar:0.2.0:compile
[INFO] |  +- pelops:pelops:jar:0.804:compile
[INFO] |  +- org.geotools:gt-main:jar:2.5-RC1:compile
[INFO] |  |  +- org.geotools:gt-api:jar:2.5-RC1:compile
[INFO] |  |  +- com.vividsolutions:jts:jar:1.9:compile
[INFO] |  |  \- jdom:jdom:jar:1.0:compile
[INFO] |  +- org.geotools:gt-shapefile:jar:2.5-RC1:compile
[INFO] |  |  +- org.geotools:gt-referencing:jar:2.5-RC1:compile
[INFO] |  |  |  +- java3d:vecmath:jar:1.3.1:compile
[INFO] |  |  |  \- org.geotools:gt-metadata:jar:2.5-RC1:compile
[INFO] |  |  |     +- org.opengis:geoapi:jar:2.2-M1:compile
[INFO] |  |  |     \- net.java.dev.jsr-275:jsr-275:jar:1.0-beta-2:compile
[INFO] |  |  \- velocity:velocity:jar:1.4:compile
[INFO] |  |     \- velocity:velocity-dep:jar:1.4:runtime
[INFO] |  +- org.geotools:gt-epsg-hsql:jar:2.5-RC1:compile
[INFO] |  |  \- hsqldb:hsqldb:jar:1.8.0.7:compile
[INFO] |  +- postgresql:postgresql:jar:8.1-407.jdbc3:compile
[INFO] |  +- javax.servlet:servlet-api:jar:2.4:compile
[INFO] |  +- javax.inject:javax.inject:jar:1:compile
[INFO] |  +- org.openrdf.sesame:sesame-rio-rdfxml:jar:2.2:compile
[INFO] |  |  +- org.openrdf.sesame:sesame-model:jar:2.2:compile
[INFO] |  |  |  +- info.aduna.commons:aduna-commons-collections:jar:2.2:compile
[INFO] |  |  |  |  \- info.aduna.commons:aduna-commons-concurrent:jar:2.2:compile
[INFO] |  |  |  \- info.aduna.commons:aduna-commons-iteration:jar:2.2:compile
[INFO] |  |  +- info.aduna.commons:aduna-commons-net:jar:2.1:compile
[INFO] |  |  \- info.aduna.commons:aduna-commons-xml:jar:2.1:compile
[INFO] |  +- org.openrdf.sesame:sesame-rio-api:jar:2.2:compile
[INFO] |  |  \- info.aduna.commons:aduna-commons-lang:jar:2.2:compile
[INFO] |  +- org.openrdf.sesame:sesame-rio-ntriples:jar:2.2:compile
[INFO] |  +- org.openrdf.sesame:sesame-rio-n3:jar:2.2:compile
[INFO] |  +- org.springframework:spring-core:jar:3.0.0.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-asm:jar:3.0.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:3.0.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-context:jar:3.0.0.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-expression:jar:3.0.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-oxm:jar:3.0.0.RELEASE:compile
[INFO] |  +- org.openrdf.sesame:sesame-rio-turtle:jar:2.2:compile
[INFO] |  |  +- info.aduna.commons:aduna-commons-io:jar:2.3:compile
[INFO] |  |  \- info.aduna.commons:aduna-commons-text:jar:2.1:compile
[INFO] |  \- au.org.ala:ala-name-matching:jar:1.0-SNAPSHOT:compile
[INFO] |     +- org.gbif:ecat-checklistbank:jar:1.0-SNAPSHOT:compile
[INFO] |     |  +- junit:junit:jar:4.4:compile
[INFO] |     |  +- uk.co.flamingpenguin.jewelcli:jewelcli:jar:0.6:compile
[INFO] |     |  +- gnu.trove:trove:jar:2.0.4:compile
[INFO] |     |  \- org.freemarker:freemarker:jar:2.3.15:compile
[INFO] |     +- portal:portal-core:jar:1.0-SNAPSHOT:compile
[INFO] |     |  +- org.springframework:spring-dao:jar:2.0:compile
[INFO] |     |  +- org.springframework:spring-support:jar:2.0:compile
[INFO] |     |  +- org.springframework:spring-aop:jar:2.0:compile
[INFO] |     |  +- org.springframework:spring-aop-cache:jar:2.0:compile
[INFO] |     |  +- org.apache.velocity:velocity:jar:1.6:compile
[INFO] |     |  |  \- oro:oro:jar:2.0.8:compile
[INFO] |     |  +- soap:soap:jar:2.3.1:compile
[INFO] |     |  +- quartz:quartz:jar:1.6.0:compile
[INFO] |     |  +- javax.transaction:jta:jar:1.0.1B:compile
[INFO] |     |  +- dom4j:dom4j-core:jar:1.4-dev-8:compile
[INFO] |     |  +- commons-math:commons-math:jar:1.1:compile
[INFO] |     |  |  \- commons-discovery:commons-discovery:jar:0.2:compile
[INFO] |     |  \- saxpath:saxpath:jar:1.0-FCS:compile
[INFO] |     \- au.com.bytecode:opencsv:jar:2.2:compile
[INFO] +- au.org.ala:bie-repository:jar:1.0-SNAPSHOT:compile
[INFO] |  +- au.org.ala:ala-logger:jar:1.0-SNAPSHOT:compile
[INFO] |  +- org.springframework:spring-orm:jar:3.0.0.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-tx:jar:3.0.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-jdbc:jar:3.0.0.RELEASE:compile
[INFO] |  +- commons-collections:commons-collections:jar:3.2:compile
[INFO] |  +- commons-dbcp:commons-dbcp:jar:1.2.1:compile
[INFO] |  |  +- commons-pool:commons-pool:jar:1.2:compile
[INFO] |  |  \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] |  +- commons-validator:commons-validator:jar:1.3.1:compile
[INFO] |  |  \- commons-digester:commons-digester:jar:1.6:compile
[INFO] |  +- net.sourceforge.htmlunit:htmlunit:jar:2.5:compile
[INFO] |  |  +- xalan:xalan:jar:2.7.1:compile
[INFO] |  |  |  \- xalan:serializer:jar:2.7.1:compile
[INFO] |  |  +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.5:compile
[INFO] |  |  +- net.sourceforge.nekohtml:nekohtml:jar:1.9.12:compile
[INFO] |  |  \- net.sourceforge.cssparser:cssparser:jar:0.9.5:compile
[INFO] |  |     \- org.w3c.css:sac:jar:1.3:compile
[INFO] |  +- net.sf.opencsv:opencsv:jar:2.1:compile
[INFO] |  +- org.jdom:jdom:jar:1.1:compile
[INFO] |  +- pdfbox:pdfbox:jar:0.7.3:compile
[INFO] |  |  +- org.fontbox:fontbox:jar:0.1.0:compile
[INFO] |  |  +- org.jempbox:jempbox:jar:0.2.0:compile
[INFO] |  |  +- bouncycastle:bcmail-jdk14:jar:136:compile
[INFO] |  |  \- bouncycastle:bcprov-jdk14:jar:136:compile
[INFO] |  +- javax.media:jai-core:jar:1.1.3:compile
[INFO] |  +- javax.media:jai-codec:jar:1.1.3:compile
[INFO] |  \- javax.media:jai-imageio:jar:1.1:compile
[INFO] +- au.org.ala:ala-common-ui:jar:1.0-SNAPSHOT:compile
[INFO] |  \- org.jasig.cas:cas-client-core:jar:3.1.10:compile
[INFO] +- au.org.ala:ala-cas-client:jar:1.0-SNAPSHOT:compile
[INFO] +- org.junit:com.springsource.org.junit:jar:4.7.0:test
[INFO] +- org.springframework:org.springframework.test:jar:3.0.5.RELEASE:test
[INFO] +- org.springframework:org.springframework.aop:jar:3.0.5.RELEASE:compile
[INFO] |  \- org.aopalliance:com.springsource.org.aopalliance:jar:1.0.0:compile
[INFO] +- org.springframework:org.springframework.beans:jar:3.0.5.RELEASE:compile
[INFO] |  \- org.springframework:org.springframework.asm:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:org.springframework.context:jar:3.0.5.RELEASE:compile
[INFO] |  \- org.springframework:org.springframework.expression:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:org.springframework.context.support:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:org.springframework.core:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:org.springframework.jdbc:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:org.springframework.orm:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:org.springframework.transaction:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:org.springframework.web:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:org.springframework.web.servlet:jar:3.0.5.RELEASE:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.6:compile
[INFO] +- org.apache.el:com.springsource.org.apache.el:jar:6.0.20:compile
[INFO] +- javax.servlet:com.springsource.javax.servlet:jar:2.5.0:provided
[INFO] +- javax.servlet:com.springsource.javax.servlet.jsp:jar:2.1.0:provided
[INFO] +- javax.servlet:com.springsource.javax.servlet.jsp.jstl:jar:1.2.0:compile
[INFO] +- org.apache.taglibs:com.springsource.org.apache.taglibs.standard:jar:1.1.2:compile
[INFO] +- log4j:log4j:jar:1.2.15:compile
[INFO] |  +- javax.mail:mail:jar:1.4:compile
[INFO] |  |  \- javax.activation:activation:jar:1.1:compile
[INFO] |  +- javax.jms:jms:jar:1.1:compile
[INFO] |  +- com.sun.jdmk:jmxtools:jar:1.2.1:compile
[INFO] |  \- com.sun.jmx:jmxri:jar:1.2.1:compile
[INFO] +- commons-lang:commons-lang:jar:2.4:compile
[INFO] +- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] |  +- commons-logging:commons-logging:jar:1.0.4:compile
[INFO] |  \- commons-codec:commons-codec:jar:1.2:compile
[INFO] +- commons-io:commons-io:jar:1.4:compile
[INFO] +- commons-fileupload:commons-fileupload:jar:1.2.1:compile
[INFO] +- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] +- org.codehaus.jackson:jackson-core-asl:jar:1.4.1:compile
[INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.4.1:compile
[INFO] +- opensymphony:sitemesh:jar:2.4.2:compile
[INFO] +- javax.validation:validation-api:jar:1.0.0.GA:compile
[INFO] \- org.hibernate:com.springsource.org.hibernate.validator:jar:4.0.0.GA:compile
[INFO]    +- javax.validation:com.springsource.javax.validation:jar:1.0.0.GA:compile
[INFO]    \- org.slf4j:com.springsource.slf4j.api:jar:1.5.6:compile

nickdos.. 13

事实证明,我们自己的两个依赖项都依赖于Spring 3.0.0.RELEASE.在以下各项中添加排除:


    
        org.springframework
        spring-core
    

解决了这个问题.

这对我来说就像一个Spring臭虫,因为我没有看到使用3.0.1,3.0.2或3.0.3的这个问题.



1> nickdos..:

事实证明,我们自己的两个依赖项都依赖于Spring 3.0.0.RELEASE.在以下各项中添加排除:


    
        org.springframework
        spring-core
    

解决了这个问题.

这对我来说就像一个Spring臭虫,因为我没有看到使用3.0.1,3.0.2或3.0.3的这个问题.

推荐阅读
周扒pi
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有