27

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
Jan Krakora
  • 2,500
  • 3
  • 25
  • 52

12 Answers12

15

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.
zb226
  • 9,586
  • 6
  • 49
  • 79
Jebil
  • 1,144
  • 13
  • 25
  • 8
    Thanks for your response but as I wrote in my question, I tried to add Maven Dependencies using 'Add' in Deployment Assembly. It works but only until I run Maven->Update Project. Then it disappears again... – Jan Krakora Jul 07 '15 at 19:39
  • @Behnil as in my first point, is `war` there in your `pom.xml` ? Also the scope of the dependencies ? – Jebil Jul 08 '15 at 03:37
  • Yes, it is. The application has been working fine for 2 years until I switched to the Eclipse Mars. I think the m2e-WTP ignores it's a maven project or something. – Jan Krakora Jul 08 '15 at 06:26
  • 1
    In my case, the missing `war` was indeed the culprit. – zb226 Nov 12 '15 at 14:13
  • Why do we need to setup this manually? Shouldn't this be m2e-wtp's job? (configure eclipse projects and m2e to deploy maven projects as it is specified by pom.xml). Maven Update feature should care about adding Maven Dependecies to the Deployment Assembly, I'm point of view. Is something missing or misconfigurated in my pom.xml which breaks m2e-wtp anyhow? It should let me know what it is then, if this is the case. m2e-wtp just seems too buggy for me... – hbobenicio May 31 '17 at 18:45
4

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 .

Kalyan Chavali
  • 1,330
  • 8
  • 24
Bhupi
  • 387
  • 3
  • 16
  • Actually I clone my GIT repo from scratch as well I create a new workspace directory for the Eclipse. Then I run "Import Maven Projects..." from Git Repositories view. Note that my repo doesn't contain any eclipse related files, so they have been generated - ie they should be fine. Anyway I will try it. – Jan Krakora Jul 10 '15 at 08:27
2

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

Hatem Badawi
  • 536
  • 4
  • 9
2

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

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.

MeanGreen
  • 3,098
  • 5
  • 37
  • 63
Patrick He
  • 11
  • 1
  • I've just tried. But the Maven Dependencies disappeared again. – Jan Krakora Oct 22 '15 at 07:40
  • Thanks for your notice. Please check the setting: inside org.eclipse.wst.common.project.facet.core.xml within .settings folder, the jst.web version should be the same as the web-app version in web.xml header : `` – Patrick He Oct 23 '15 at 07:53
  • I've found and yes, it's the same as web-app version in web.xml header. – Jan Krakora Oct 23 '15 at 11:19
1

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.

Mukul Bansal
  • 878
  • 8
  • 10
1

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.

  • Thanks for the hint, I just disabled workspace resolution and the Maven dependencies magically reappeared in the deployment assembly... I could enable again without adverse effect – Alex R Apr 19 '19 at 11:47
0

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.

Elias
  • 1
0

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> -->
Alex R
  • 808
  • 2
  • 10
  • 26
0

My solution was:

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

roger
  • 1
0

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

Eric
  • 1,279
  • 1
  • 11
  • 8
0

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

Fulvius
  • 511
  • 6
  • 15