NoClassDefFoundError springframework context WebApplicationContext

NoClassDefFoundError springframework context WebApplicationContext

If you see below error:

Caused by: java.lang.NoClassDefFoundError: org/springframework/web/context/WebApplicationContext

Caused by: java.lang.NoClassDefFoundError: org/springframework/web/context/WebApplicationContext
	at java.lang.Class.getDeclaredFields0(Native Method)
	at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
	at java.lang.Class.getDeclaredFields(Class.java:1743)
	at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
	at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261)
	at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:140)
	at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)
	at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:403)
	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:879)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:374)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5355)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	... 7 more
Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.WebApplicationContext
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
	... 21 more

Solution: You will have to add spring-web.x.x.0.jar on your class path. If you have already added it your class path please see below:

  • For Maven project: Delete your local repository completely and then right click your project –> Maven –> Update project. Maven will build fresh local repository again and issue should be resolve.
  • For eclipse project using lib folder: Do clean and build your eclipse project. Sometime eclipse goes out of date.

Leave a Reply

Your email address will not be published. Required fields are marked *