Missing maven dependencies from deployment assembly
Asked Answered
B

13

28

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
Bahrain answered 30/6, 2015 at 20:52 Comment(3)
Do you have the Google plugin for Eclipse installed? If so, you might be running into this issue.Freehand
@Freehand No, I don't. But all symptoms seem similar.Bahrain
probably same on official issue tracker: bugs.eclipse.org/bugs/show_bug.cgi?id=462591Leacock
F
17

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.
Flocculate answered 7/7, 2015 at 6:14 Comment(5)
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...Bahrain
@Behnil as in my first point, is <packaging>war</packaging> there in your pom.xml ? Also the scope of the dependencies ?Flocculate
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.Bahrain
In my case, the missing <packaging>war</packaging> was indeed the culprit.Schlicher
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...Leisure
F
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 .

Fullback answered 9/7, 2015 at 14:19 Comment(1)
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.Bahrain
S
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

Stool answered 30/12, 2015 at 22:56 Comment(0)
W
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...)

Witling answered 25/5, 2016 at 9:58 Comment(0)
T
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.

Tsar answered 22/10, 2015 at 7:4 Comment(3)
I've just tried. But the Maven Dependencies disappeared again.Bahrain
Thanks for your notice. Please check the setting: <installed facet="jst.web" version="3.0"/> 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 : <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">Tsar
I've found <installed facet="jst.web" version="2.5"/> and yes, it's the same as web-app version in web.xml header.Bahrain
D
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.

De answered 25/11, 2016 at 11:59 Comment(0)
R
1

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.

Reconstructionism answered 4/3, 2017 at 22:36 Comment(0)
M
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.

Manzo answered 23/2, 2018 at 20:22 Comment(1)
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 effectIlise
I
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> -->
Ilise answered 21/8, 2017 at 20:47 Comment(0)
Z
0

My solution was:

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

Zeppelin answered 26/7, 2018 at 15:25 Comment(0)
S
0

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

Sesterce answered 12/1, 2019 at 2:18 Comment(0)
C
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

Czardas answered 27/3, 2019 at 17:33 Comment(0)
H
0

In my case the other answers didn't work until I make sure that all the relevant configurations relative to the Java version where aligned. That means:

  • Java Compiler Level
  • maven-compiler-plugin java target version
  • JRE Runtime installed
  • Java Proyect facet
Headstall answered 7/11, 2023 at 16:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.