Dynamic Web Module

Upgrading/Changing Dynamic Web Module Version in Maven Spring Application.

For this purpose I am just referencing the same sample application which we created in my last post i.e. “CREATING RESTFUL WEB SERVICES IN JAVA USING SPRING 4.2.5”.We will upgrade it’s Dynamic Web Module to 3.0,which is currently 2.3.

1)If you will try to change it to 3.0 then you will get a message like:-
“Cannot change version of project facet Dynamic Web Module to 3.0”.

2016March16_1

2)Uncheck this with version i.e. 3.0 and click “Apply” and than click “OK”.

3)Again go to same screen i.e. Project Facets version to “3.0” will be already there and now make it checked now.

2016March16_2
Now Click on “OK” and then on “Apply”.You will be see its impact in project and will see that there is a new folder “WebContent”.
2016March16_3

4)Clean and build your project.Now you will see error as :-
2016March16_4

5)The reason for this is the that we need to change structure of web.xml for 3.0.
So Make your web.xml like below now:-

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		 xmlns="http://java.sun.com/xml/ns/javaee"
		 xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
		 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
		 id="WebApp_ID"
		 version="3.0">

	<display-name>Archetype Created Web Application</display-name>

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/rest-servlet.xml</param-value>
	</context-param>

	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<servlet>
		<servlet-name>rest</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value></param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<!--This Servlet mapping will handle all incoming requests -->
	<servlet-mapping>
		<servlet-name>rest</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>

</web-app>
    

Now clean and build your project.Things should be working fine with web module 3.0.

Hope this will help someone.