Posted In: Maven

Problem with Maven + Servlet3 + archetype-webapp and how to solve it

There are multiple articles on Web on how to set up maven web project in eclipse. Most of these articles do it through external maven installation and use maven-archtype-webapp. Problem with this approach is you may not have external maven in organization and usually is not allowed with out approval. Then there is problem of servlet version in this archtype which is 2.3. Your app server may not even support this anymore. Changing it afterwards is very tedious. I am adding steps that I have taken to it through eclipse plugin and then changing it to higher JDK, Servlet facet. This is the only way I have found which works.
See my other article with using correct arch type

Maven + Eclipse + Servlet3 + Tomcat9 – Best way to create Servlet3 maven project using eclipse


Steps
1. Download eclipse Mars or Neon. This has already maven plugin installed
2. Select create new maven project
3. Select maven-archtype-webapp
4. Add Group id (example com.javausecase)
5. Add Artifact id (example ExampleProject)
6. Create project
7. Select Properties -> Project Facets
8. Now uncheck Dynamic Web Module and Apply
9. Next change Java level to > 1.6 and Apply
10. Now check Dynamic Web Module and set to 3.0. Don’t forget to check generate web.xml check box and Apply
11. Assign Runtime. If not created then create the server before doing this step
12. Run and test

Select create new maven project


Select maven-archtype-webapp

Add Group id (example com.javausecase)
Add Artifact id (example ExampleProject)


Select Properties -> Project Facets
Now uncheck Dynamic Web Module and Apply

Next change Java level to > 1.6 and Apply

Now check Dynamic Web Module and set to 3.0. Don’t forget to check generate web.xml check box and Apply

Assign Runtime. If not created then create the server before doing this step


Tags: , , , ,

by , on January 17th, 2017

  • Categories