19
  1. Create a web project using Maven:

    mvn archetype:generate -DgroupId=com.trial -DartifactId=message 
       -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
    
  2. Convert the project to Eclipse web project using:

    mvn eclipse:eclipse -Dwtpversion=2.0
    
  3. Import existing project into Eclipse:

enter image description here

The project icon contains an folder instead of a web icon and folder icon. I find this a bit strange and when I try to run also, the run on server option is missing. I am sure I followed the steps correctly. Where may I be lagging to obtains such a result ?

2
  • What does that red mark say, when you see it in Problems view?
    – Rohit Jain
    Aug 3, 2013 at 19:13
  • It said there were some missing libs. I added them and now still it seems as a Java app not a web app. . Aug 3, 2013 at 19:44

3 Answers 3

24

I have the below's suggestions :

  1. First check whether your eclipse is in Jave EE Perspective or not. If it was in only Java perspective, run option will not come.

  2. Right click on your project, go to properties.

    Click on Project Facets

    Check whether Dynamic Web module is check marked or not. If not just check marked it.

1
  • This works for me, also check on java ,if not checked. Mar 12, 2017 at 8:10
1

WTP version is rather old, you should add a web project features instead. Edit the .project file and write under the natures tag

<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>

and under the buildSpec tag add builders

<buildCommand>
    <name>org.eclipse.wst.common.project.facet.core.builder</name>
    <arguments>
    </arguments>
</buildCommand>
<buildCommand>
    <name>org.eclipse.wst.validation.validationbuilder</name>
    <arguments>
    </arguments>
</buildCommand>
1

If you want to create maven webapp by only using eclipse without switching to command line, then following the below steps is better.

Following steps work in eclipse 2020-06

  1. File->New->Maven Project
  2. Choose "Create a simple project (skip archetype selection)"
  3. Choose packaging as "war" (this will create both webapp and java folders)
  4. Create the project after specifying group id and artifact id
  5. Update pom.xml with java and compiler versions, then right click on project, select Maven->Update project
  6. If the project is not faceted form (Its not in faceted form if on expanding project in Project explorer, it doesn't show details such as "Deployment Descriptor" and "JAX-WS Web Services", this happened in one of my eclipse installation and i had no clue why), then do the following steps
    1. right click on project, go to Properties, click on Project Facets, convert to faceted form, choose correct "Dynamic Web Module" version, enable the checkbox and also choose correct Java Facet version.
    2. "Further configuration available" gets displayed in that window, click on it and specify WebContent folder. (replace WebContent by src/main/webapp)
    3. If you want to run the application in servers configured in eclipse, then specify maven dependencies to be deployed in "Deployment Assembly". This will deploy maven "provided" dependencies also, but i think its fine for testing. For actual distribution, you can supply war file generated from maven package.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.