26
votes

I've recently upgraded from eclipse 4.4.2 (Luna) to 4.5 (Mars). My dynamic web project now doesn't include the Maven Dependencies in its deployment assembly "Project->Properties->Deployment assembly".

I can add them manually (using "Project->Properties->Deployment assembly->Add->Java Build Path Entries->Maven Dependencies"), but every time I run "Project->Maven->Update Project Configuration", the Maven Dependencies are removed again.

Note that I run the project using the Apache Tomcat Server within the Eclipse IDE.

I have installed

  • m2e 1.6.0.20150526-2032
  • m2e-wtp 1.2.0.20150602-1740
12
Do you have the Google plugin for Eclipse installed? If so, you might be running into this issue. - cyfur01
@cyfur01 No, I don't. But all symptoms seem similar. - Behnil

12 Answers

13
votes

This should have nothing to do with eclipse and m2eclipse, and optionally for better support - m2e-wtp. Also, you don't need copy-dependencies. Here are a few possible reasons:

  • you should invoke mvn package (or right-click > maven > package) and obtain a war file - the (in the pom) must be war

    <packaging>war</packaging>

  • your dependencies should be with the default scope (if they are provided or test they will not be included in the archive)

  • if you are running the project as dynamic web project on a server within eclipse, then you should open the project properties (right click > properties) and select "Deployment Assembly". There click "add", select "build path entries", and choose "maven dependencies". This will instruct WTP to send the maven dependencies to the server dir.
4
votes

can you please try to cleanse setup by following below steps

  1. disable Maven nature of application :

Right Click Project -> Maven -> Disable Maven Nature
  1. open cmd , go to project location , Run mvn clean install eclipse:eclipse -Dwtpversion=2.0(This goal just deletes the .project, .classpath and .settings/ files/directories. You can also just remove those files (again while the project is open) instead of running mvn eclipse clean.)

  2. Re-enable the maven nature. (Most of the time, this can be done by right-clicking on the project in question in the package explorer pane, and then choosing 'Configure'-> 'Convert to Maven Project')

other things you can try of

1. reimport project into some other workspace 
2. resintall eclipse 

if it still didn't solve your problem , most probably you might need to raise Jira to eclipse team .

2
votes

I solved the same issue this way:

  1. Open pom.xml and make Packaging war .
  2. Right click the project and select Maven>Update Project.

Will update the project without deleting the Maven Dependencies from Deployment Assembly ; And if the Maven Dependencies is missing the Maven>Update Project will automatically add it to the project Deployment Assembly

2
votes

I solved a similar issue by doing following actions on my web project:

  • removing maven nature
  • cleaning up all m2e generated files
  • adding maven nature
  • alt + F5

Note : I had this issue after adding maven nature to my java projects in order to use them with m2e instead of prior maven eclipse plugin (legacy...)

1
votes

I recently had the same issue just like your description above and I got it working this way:

  1. right-click on project > Maven > Disable Maven Nature
  2. right-click on project > Configure > Convert to Maven Project

Then call the Maven update project, the Maven dependencies will not disappear from the view of Deployment Assembly again.

1
votes

What I was doing - I was replacing the default web.xml file with my own web.xml.

The moment I replaced my default web.xml (which is created while creating a new maven web project), the Maven Dependencies disappeared from the Deployment Assembly. So, instead of replacing, I copy-pasted my content in the original/default web.xml.

That resolved my problem.

1
votes

my case was the following: I wasn't even able to choose the "Maven Dependencies" for the "Deployment Assembly".

I could finally (!) solve it this way: rightclick on project -> Maven -> Enable Workspace Resolution

watch out again in "Deployment Assembly" (project properties), if it worked.

0
votes

I resolved this problem as follows;

  1. copy the content of the web.xml file and save it somewhere for later use.

  2. delete the web.xml file.

  3. Right click on the project -> Java EE Tools -> Generate Deployment Descriptor Stub

step 3 will generate the web.xml file in the WEB-INF folder. then you can paste your saved content in step 1 to the newly generated web.xml file.

After this your maven dependencies will not be removed from the deployment Assembly.

0
votes

In my case, it was a pluginExecutionFilter in the pluginManagement section in the pom.xml.

Removing the section for org.apache.maven.plugins:maven-war-plugin eliminated the problem of the maven dependencies that would vanish from the deployment assembly, along with the issue that after adding the maven dependencies manually, deployment would also install test dependencies:

                <!-- Remove to eliminate vanishing maven dependencies
                           <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.apache.maven.plugins
                                    </groupId>
                                    <artifactId>
                                        maven-war-plugin
                                    </artifactId>
                                    <versionRange>
                                        [3.0.0,)
                                    </versionRange>
                                    <goals>
                                        <goal>war</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution> -->
0
votes

My solution was:

Eclipse > Window > Preferences > Maven > Java EE Integration > Check "Enable Java EE configuration"

0
votes

My solution is because web.xml version is not compatible, change it from 2.4 to 3.0.

0
votes

Right Click on Project > Properites> Maven
Uncheck and Apply "Resolve dependencies from Wrokspace projects". After that check "Resolve dependencies from Wrokspace projects" and click OK.

enter image description here