12

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...

Aritz
  • 30,971
  • 16
  • 136
  • 217

3 Answers3

5

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

Thomas
  • 1,085
  • 9
  • 14
  • I was expecting another kind of response, but I suposse is plugin's bug. You deserve the bounty because of the link to it. – Aritz Feb 15 '13 at 14:02
  • bug has been fixed on 2015-03-05 15. I tested the snapshot m2e-wtp from http://download.eclipse.org/m2e-wtp/snapshots/mars/ – cthiebaud Mar 06 '15 at 14:04
1

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.

Ariel Carrera
  • 5,113
  • 25
  • 36
  • Still have to try your solution, what I do is just include the transitive dependency depending on the profile. Anyway, muchas gracias. – Aritz Oct 09 '13 at 14:53
1

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.

artbristol
  • 32,010
  • 5
  • 70
  • 103
  • Yeah, that's exactly what I do. Furthermore, I include B-dependencies.jar depending on the profile (I use it with eclipse profile and not with production one, as the problem is related with eclipse). I changed question title to unrelate it to Tomcat ;-) – Aritz Oct 09 '13 at 14:49
  • The m2e-wtp founder has [a similar solution](https://bugs.eclipse.org/bugs/show_bug.cgi?id=398138#c6) which is not working for me. Not totally solved at 1.0.1 yet. – Aritz Oct 15 '13 at 13:32