| Summary: | Maven dependencies in webapps may override each other due to naming scheme | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Sune Wettersteen <sune> | ||||
| Component: | m2e | Assignee: | Project Inbox <m2e.core-inbox> | ||||
| Status: | CLOSED NOT_ECLIPSE | QA Contact: | |||||
| Severity: | critical | ||||||
| Priority: | P3 | CC: | matthew | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 201243 [details]
A web deployment assembly containing two dependencies with the same artifact ID which results in identical (and thus conflicting) deployment names
m2e-wtp isn't part of the Eclipse project, issues for it should be filed at: https://issues.sonatype.org/browse/MECLIPSEWTP Thanks, I will file the report with them instead :) |
Maven dependencies in webapps may override each other due to naming schemes. Maven will name jar files based on the artifact ID rather than using a fully qualified name based on both the group ID and the artifact ID. Due to the flat nature of the web application libraries this means that two different maven dependencies with identical artifact IDs will override each other. The consequence of this is that a project depending on more than one artifact with the same artifact ID (and version), will only have one of these deployed to the web application (WEB-INF/lib). A practical example: Including version 1.0 of com.googlecode.wicketelements » common org.codehaus.hydra-cache » common will attempt to put two "common-1.0.jar" (or similar) classes in the WEB-INF/lib directory when deploying the web app. Of course due to this naming scheme, only one of the jar files can exist in the lib folder. Ultimately this results in ClassNotFoundExceptions or similar. As seen in the attached screenshot, the web deployment descriptor generated for a project which has two dependencies with the same artifact ID and the deployment path generated for each of them (which are identical). This naming scheme may be standard for maven, but in order to overcome this deficiency the maven-war-plugin offers a way to map dependency names/version to file names: <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <archiver> <manifest_entry>value</manifest_entry> </archiver> <archive> <manifest> <addClasspath>true</addClasspath> </manifest> </archive> <attachClasses>true</attachClasses> <outputFileNameMapping>@{groupId}@-@{artifactId}@-@{version}@.@{extension}@</outputFileNameMapping> </configuration> </plugin> The "outputFileNameMapping" would ensure that dependencies get fully qualified names. However, even though this is configured in the project pom file, it is not reflected in the web deployment assembly used by eclipse. The m2e functionality should definitely be able to be able to pick up this configuration and ensure that the web deployment assembly generated reflects these settings. I see this as a critical bug (or missing functionality) since dependency inclusion becomes random when having dependencies with identical artifact IDs. We've also experienced that the jar file which prevails and gets deployed in the web app is not stable across platforms (eclipse running on windows and mac do not end up including the same jar file). In all cases you will be missing a dependency which may end up having serious consequences at runtime.