java

java.lang.ClassNotFoundException: org.springframework.web.context.support.StandardServletEnvironment

While upgrading from Spring 3.0.5 to 3.1.1.RELEASE I started getting following exception.

java.lang.ClassNotFoundException: org.springframework.web.context.support.StandardServletEnvironment
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
	at org.springframework.web.servlet.HttpServletBean.<init>(HttpServletBean.java:90)
	at org.springframework.web.servlet.FrameworkServlet.<init>(FrameworkServlet.java:211)
	at org.springframework.web.servlet.DispatcherServlet.<init>(DispatcherServlet.java:323)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at java.lang.Class.newInstance0(Class.java:355)
	at java.lang.Class.newInstance(Class.java:308)

After some research I came to conclusion that the file have been factored out into ‘spring-web’ subproject.

So to solve this all we need to do is include ‘spring-web’ dependency

            <dependency>
 
         	<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>${spring.version}</version>
			<exclusions>
				<exclusion>
					<groupId>commons-logging</groupId>
					<artifactId>commons-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

Hope this might help someone save some time.

Leave a Reply

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

* Copy This Password *

* Type Or Paste Password Here *