java.lang.NoSuchFieldError: APPLICATION_CONTEXT_ID

2020-04-21 07:14发布

问题:

I am receiving this error on running my project and the result is 404 ultimately. The project is made on Spring framework.

I read a lot of posts and found that there is either a mix up of jars or extra jars. Following which I tried to organize my jars. The following list is what I have in my build path:

antlr-2.7.6.jar  
asm.jar  
asm-attrs.jar  
cglib-2.2.jar  
commons-beanutils-1.7.0.jar  
commons-collections-3.1.jar  
commons-digester-1.8.jar  
commons-email-1.0.jar  
commons-fileupload-1.1.1.jar  
commons-io-1.2.jar  
commons-lang-2.5.jar  
commons-logging-1.1.1.jar  
displaytag-1.0-b3.jar  
dom4j-1.6.1.jar  
ehcache-1.1.jar  
hibernate3.jar  
hibernate-jpa-2.0-api-1.0.0.Final.jar  
hibernate-validator-4.0.2.GA.jar  
hsqldb.jar  
itext-2.1.3.jar  
javassist-3.12.0.GA.jar  
jdom.jar  
jstl-1.2.jar  
jta-1.1.jar  
log4j-1.2.14.jar  
msbase.jar  
mssqlserver4v65.jar  
msutil.jar  
mysql.jar  
mysql-connector-java-5.1.15-bin.jar  
ojdbc14.jar  
persistence-api-1.0.jar  
poi-3.0-alpha2.jar  
servlet-2.3.jar  
slf4j-api-1.6.6.jar  
slf4j-log4j12-1.5.6.jar  
slf4j-simple-1.6.6.jar  
spring-asm-3.0.3.RELEASE.jar  
spring-beans-3.0.3.RELEASE.jar  
spring-context-3.0.3.RELEASE.jar  
spring-core-3.0.3.RELEASE.jar  
spring-expression-3.0.3.RELEASE.jar  
spring-hibernate3-2.0.8.jar  
spring-web-3.0.3.RELEASE.jar  
spring-webmvc-3.0.3.RELEASE.jar  
sqljdbc4.jar  
standard.jar  
tree.jar  
validation-api-1.0.0.GA.jar  
wloracle.jar  
wlsqlserver.jar  

Here goes the stacktrace

SEVERE: Error loading WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@ca2dce
org.springframework.web.servlet.DispatcherServlet
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1083)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4364)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
    at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
    at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
    at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)
    at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:315)
    at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:148)
    at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:420)
    at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:483)
    at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1433)
    at org.apache.jasper.compiler.Parser.parse(Parser.java:133)
    at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:216)
    at org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:153)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)

I have deleted many jars, which I thought, are repetitive.
My question is whether all these jars are exactly enough or are there duplicates?
Please help, this 404 is killing me...

回答1:

You have a lot of duplicated jars there:

antlr
jta
mysql-connector
javassist
mssqlserver

I would make sure you only have one of each before continuing, work out which version you need and include that one.

If you are not sure how to do this, let us know how you are importing your dependencies.

It would also be helpful to see the stacktrace you are seeing and a simplified Spring context that causes the error.


If you look at this question: JasperException: absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved

You need to make sure you have the right version of JSTL, maybe once you remove the duplicate JSTL it may fix that error.



回答2:

My guess would be deleting spring.jar and spring-1.2.6.jar ; they conflict with spring*3.0.3.RELEASE.jars

And my two cents would be using maven when working with spring framework.