WTP - m2e not deploying transitive dependencies

2019-03-25 08:17发布

I have a web application which is structured in this way:

A.jar -> B.war -> C.war

I'm using Eclipse Juno and the WTP version is 1.1. The A.jar is a workspace utility project which is being included by B.war. B.war is a war project that is included by C.war as an overlay. That's the way I'm doing that:

<dependency>
    <groupId>com.projects</groupId>
    <artifactId>B</artifactId>
    <version>1.0-SNAPSHOT</version>
    <type>war</type>
    <scope>runtime</scope>
</dependency>

After that, I deploy the C project to the Tomcat server. That works like a charm if I manually deploy the Maven generated war to the Tomcat, because A.jar is included in WEB-INF/lib. However my problem comes when I let m2e-wtp do the deploy, because it's doing the overlay properly but not including the A transitive dependency. I tried including it as a pom, as I read somewhere around here, but I have the same result.

<dependency>
    <groupId>com.projects</groupId>
    <artifactId>B</artifactId>
    <version>1.0-SNAPSHOT</version>
    <type>war</type>
    <scope>runtime</scope>
</dependency>

<dependency>
    <groupId>com.projects</groupId>
    <artifactId>B</artifactId>
    <version>1.0-SNAPSHOT</version>
    <type>pom</type>
</dependency>

I'm using the newest versions of m2e (1.2) and m2e-wtp (0.16) and have my projects updated with the Maven configuration.

Is it an m2e-wtp issue or simply do I have to organize my project in other way?


EDITED

I noticed m2e-wtp configuration is stored into Eclipse's project./settings/org.eclipse.wst.common.component file. That's how it looks for my war:

<dependent-module deploy-path="/"
    handle="module:/overlay/prj/B?includes=**/**&amp;excludes=META-INF/MANIFEST.MF">
    <dependency-type>consumes</dependency-type>
</dependent-module>
<dependent-module deploy-path="/"
    handle="module:/overlay/slf/?includes=**/**&amp;excludes=META-INF/MANIFEST.MF">
    <dependency-type>consumes</dependency-type>
</dependent-module>

As I can see the war dependency is set for consume while the jar dependencies are set for use.

Released m2e-wtp version 0.17 doesn't seem to fix it.


EDITED (2013-08-30)

Today I was back to the same problem. Even I have Eclipse kepler installed with the latest stable release of WTP out of the box, this problem seems to persist. I thought it was solved, but I apparently mischeck it...

3条回答
Deceive 欺骗
2楼-- · 2019-03-25 08:38

I also have this problem. I have an ugly workaround:

Put all the original war's dependencies in a separate project (type jar) and make both original war and overlay war depend on that. So for the example:

A.jar -> B.war -> C.war

becomes

A.jar -> B-dependencies.jar (new module called B-dependencies created)

B-dependencies.jar -> B.war

B-dependencies.jar -> C.war

Note that it's not specific to Tomcat; I'm using JBoss.

查看更多
手持菜刀,她持情操
3楼-- · 2019-03-25 08:45

I think it is not a problem of your project organization. Your issue is very similar to this m2e-wtp bug report.

查看更多
Summer. ? 凉城
4楼-- · 2019-03-25 08:54

It seems to be a Eclipse Juno and WTP Plugin problem.

I had the same problem and i solved in this way:

  1. Backup your eclipse workspace and your project code
  2. remove your project from eclipse (without remove the contents)
  3. open a command terminal (cmd)
  4. run mvn eclipse:clean
  5. run mvn eclipse:eclipse -Dwtpversion=2.0
  6. edit your eclipse classpath file with a text editor: %PROJECT_PATH%\.classpath
  7. remove all lines with attribute kind="var" from your .classpath file. For example:

    < classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar" sourcepath="M2_REPO/javax/servlet/servlet-api/2.5/servlet-api-2.5-sources.jar"/>

  8. save file & close editor.
  9. in eclipse, click on: file->Import...->Maven->import existing maven project, and import your project again
  10. Maven -> Update Project (if you want)
You could see on deployment assembly in eclipse project properties that problem is solved and the maven dependencies are there.

Hope this helps.

查看更多
登录 后发表回答