6

Eclipse Indigo SR 1, wtp 3.3.0, m2eclipse 1.0.100.

When publishing a project to WTP, I'm getting strange behavior with one of the dependencies; instead of putting the jar in the WEB-INF/lib folder, it's creating a folder named for the expected jar, and then putting the source tree (apparently) from that project under that folder. I can't see anything in the dependency's pom.xml or this project's pom.xml that could be causing this.

Other dependencies are being brought over just fine, as jars.

My test project's pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>test</groupId>
  <artifactId>dwhwtptest</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>dwhwtptest Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>org.onebusaway</groupId>
      <artifactId>onebusaway-nyc-transit-data</artifactId>
      <version>2.0.3-SNAPSHOT</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>dwhwtptest</finalName>
  </build>
</project>

Here's what ends up being published at workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps:

$ find  dwhwtptest/
dwhwtptest/
dwhwtptest//index.jsp
dwhwtptest//META-INF
dwhwtptest//META-INF/MANIFEST.MF
dwhwtptest//META-INF/maven
dwhwtptest//META-INF/maven/test
dwhwtptest//META-INF/maven/test/dwhwtptest
dwhwtptest//META-INF/maven/test/dwhwtptest/pom.properties
dwhwtptest//META-INF/maven/test/dwhwtptest/pom.xml
dwhwtptest//WEB-INF
dwhwtptest//WEB-INF/lib
dwhwtptest//WEB-INF/lib/onebusaway-nyc-transit-data-2.0.3-SNAPSHOT.jar
dwhwtptest//WEB-INF/lib/onebusaway-nyc-transit-data-2.0.3-SNAPSHOT.jar/META-INF
dwhwtptest//WEB-INF/lib/onebusaway-nyc-transit-data-2.0.3-SNAPSHOT.jar/META-INF/MANIFEST.MF
dwhwtptest//WEB-INF/lib/onebusaway-nyc-transit-data-2.0.3-SNAPSHOT.jar/org
dwhwtptest//WEB-INF/lib/onebusaway-nyc-transit-data-2.0.3-SNAPSHOT.jar/org/onebusaway
dwhwtptest//WEB-INF/lib/onebusaway-nyc-transit-data-2.0.3-SNAPSHOT.jar/org/onebusaway/nyc
dwhwtptest//WEB-INF/lib/onebusaway-nyc-transit-data-2.0.3-SNAPSHOT.jar/org/onebusaway/nyc/transit_data
dwhwtptest//WEB-INF/lib/onebusaway-nyc-transit-data-2.0.3-SNAPSHOT.jar/org/onebusaway/nyc/transit_data/model
dwhwtptest//WEB-INF/lib/onebusaway-nyc-transit-data-2.0.3-SNAPSHOT.jar/org/onebusaway/nyc/transit_data/model/NycQueuedInferredLocationBean.java
dwhwtptest//WEB-INF/lib/onebusaway-nyc-transit-data-2.0.3-SNAPSHOT.jar/org/onebusaway/nyc/transit_data/model/NycVehicleManagementStatusBean.java
dwhwtptest//WEB-INF/lib/onebusaway-nyc-transit-data-2.0.3-SNAPSHOT.jar/org/onebusaway/nyc/transit_data/services
dwhwtptest//WEB-INF/lib/onebusaway-nyc-transit-data-2.0.3-SNAPSHOT.jar/org/onebusaway/nyc/transit_data/services/ConfigurationService.java
dwhwtptest//WEB-INF/lib/onebusaway-nyc-transit-data-2.0.3-SNAPSHOT.jar/org/onebusaway/nyc/transit_data/services/VehicleTrackingManagementService.java
dwhwtptest//WEB-INF/web.xml

And here's the pom.xml for the dependency, the onebusaway-nyc-transit-data module:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>onebusaway-nyc</artifactId>
        <groupId>org.onebusaway</groupId>
        <version>2.0.3-SNAPSHOT</version>
    </parent>
    <groupId>org.onebusaway</groupId>
    <artifactId>onebusaway-nyc-transit-data</artifactId>
    <packaging>jar</packaging>

    <name>onebusaway-nyc-transit-data</name>
    <description>Common interfaces and classes for exchanging transit data between UI front-end and transit back-end data sources.</description>

    <build>
        <finalName>onebusaway-nyc-transit-data</finalName>
    </build>
</project>

Suggestions? Anything else I can investigate to try to figure out what's going on here?

denishaskin
  • 3,305
  • 3
  • 24
  • 33
  • 1
    Okay, I seem to have a workaround but I'd still like to know why it doesn't work as expected. The misbehaving dependency was listed in Web Deployment Assembly for the test project, but what I did was remove it and add it back, via the Eclipse UI. This time when I added the project to the server and published, the jar is there, correctly. Thoughts? – denishaskin Jan 20 '12 at 16:48
  • I have exactly the same issue. As far as I can see from the webapps folder where eclipse is publishing (which you usually will find under /.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps) Eclipse is sometimes publishing jar containing sources instead of jars containing classes. This happens quite often in my project where I have a big maven project containing multiple subprojects. Currently the workaround does not help as well :( I am still trying to figure out what's happening – Bruno Bossola Apr 26 '12 at 13:37
  • Find a consistently working workaround, see my answer. – Bruno Bossola Apr 26 '12 at 15:26
  • [This question](http://stackoverflow.com/questions/11364556/why-does-the-wtp-plugin-deploy-one-maven-dependency-as-a-folder-instead-of-a-ja) also describes the same problem, although it's asking why does it happen – chrisbunney Aug 08 '12 at 09:51

3 Answers3

6

A colleague of mine provided me an approach that fixed the issue, but it requires few manual steps.

  • remove the project from your eclipse

  • go to your maven root folder with a terminal and kill all the eclipse stuff using this command (you will have to do this twice):

    $> find . -iname ".settings" -exec rm -rf '{}' \; ; find . -iname ".project" -exec rm -rf '{}' \; ; find . -iname ".classpath" -exec rm -rf '{}'

  • on your maven root, execute this command:

    $> mvn -Dwtpversion=2.0 eclipse:eclipse

  • import your project back in eclipse: everything will now work and eclipse will be publishing jars containing code :)

HTH, Bruno (credits to Theodore!)

Bruno Bossola
  • 1,128
  • 1
  • 13
  • 24
1

I suggest trying out the m2e-wtp plugin in addition to your currently installed m2e plugin (which doesn't contain support for WTP based projects) This plugin is available in the Eclipse Marketplace via the embedded Marketplace client or on the web (http://marketplace.eclipse.org/content/maven-integration-eclipse-wtp). It provides a tighter Maven integration with WTP and should improve the overall Maven with WTP experience.

Neil H
  • 356
  • 1
  • 6
0

If things still don't work go delete the publish folder. It will look something like:

<Path To Your IDE>\.metadata\.plugins\org.eclipse.wst.server.core\tmp0

First make sure you REMOVE the project under Tomcat or whatever other server you are using from withing the IDE. Then close the ID or you cannot delete the folder.

Once you do this, you can run your maven clean/build/install command and deploy your project.

If this does not work, this problem isn't related to the IDE or the Application Server.

Hauleth
  • 22,873
  • 4
  • 61
  • 112
Mukus
  • 4,870
  • 2
  • 43
  • 56