Maven Integration for Eclipse

Workspace dependencies not added to classpath container for WST dynamic web projects

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.0.12
  • Fix Version/s: 0.9.4
  • Component/s: WTP integration
  • Labels:
    None
  • Environment:
    eclipse europa jee fall (3.3.1), windows xp
  • Number of attachments :
    3

Description

If a project dependency for a dynamic web project is also an open workspace project, then the dependency is not added to the maven classpath container.

I'm attaching a set of projects to demonstrate the problem:

ProjOne - a Java/JAR project
ProjTwo - a Java/JAR project that depends on ProjOne - the dependency shows up OK
ProjThree - a dynamic web project/WAR that depends on ProjOne - the dependency does not show up

If ProjOne is installed in the local repository, and then closed, ProTwo and ProjThree will both correctly resolve the dependency to the JAR from the repository.

Also, if the following lines are removed from the ProjThree's .project file, and the project is cleaned (with ProjOne open), the dependency will resolve correctly to the workspace project.

<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>

Issue Links

Activity

Hide
Mark Hewett added a comment -

This "issue" seems to be by design per MNGECLIPSE-105.

Show
Mark Hewett added a comment - This "issue" seems to be by design per MNGECLIPSE-105.
Hide
Olivier LE MERDY added a comment - - edited

Versions used

Eclipse 3.3.1 for both Linux and Windows.
m2eclipse 0.0.12
WST 2.0.1

Further consideration

I got the very same issue reported here, on both Linux and Windows platforms. I played a bit further with project properties and created different types of WTP projects:

  • Utility module with Maven artifact package set to "jar"
  • EJB module with Maven artifact package set to "ejb"
  • Application module with Maven artifact package set to "jar"
  • Web module with Maven artifact package set to "war"

All these projects have exactly the same .project files (but, of course, project name) with the same builders. Interestingly enough, the only project that cannot resolve artifacts corresponding to open projects is the web module one.

Playing with installed facets (for example removing Web facet and adding Utility one) does not change anything to the problem. However changing the owning artifact package does the trick! If you simply switch package type from "war" to "jar" in the Web module pom.xml (even if it does not make sens ), the artifact is automagically resolve from the project.

Test case

So here is the test case:

  • Create a Java project "ProjectJar" with a maven packaging of "jar"
  • Create a Dynamic Web Project "ProjectWar" with a maven packaging of "war"
  • Add "ProjectJar" to "ProjectWar" maven dependencies and check it is not resolved at all (neither from repository nor workspace)
  • Close "ProjectJar" and check it is resolved from repository (assuming you mvn-installed ProjectJar)
  • Re-open the project and switch ProjectWar packaging from "war" to "jar" in its pom.xml
  • Check the dependency resolves from workspace!

There is obviously an issue with handling of "war" projects combined with facets...

Criticity

As of me, this bug is a really serious one. Working on a Web project using multiple artifacts/Eclipse project makes me opening, closing and installing artifacts all the time in order to make the web-app project compile with latest changes from depending modules. A bug fix would be truly appreciated . Please ask if further test is needed.

Show
Olivier LE MERDY added a comment - - edited

Versions used

Eclipse 3.3.1 for both Linux and Windows. m2eclipse 0.0.12 WST 2.0.1

Further consideration

I got the very same issue reported here, on both Linux and Windows platforms. I played a bit further with project properties and created different types of WTP projects:
  • Utility module with Maven artifact package set to "jar"
  • EJB module with Maven artifact package set to "ejb"
  • Application module with Maven artifact package set to "jar"
  • Web module with Maven artifact package set to "war"
All these projects have exactly the same .project files (but, of course, project name) with the same builders. Interestingly enough, the only project that cannot resolve artifacts corresponding to open projects is the web module one. Playing with installed facets (for example removing Web facet and adding Utility one) does not change anything to the problem. However changing the owning artifact package does the trick! If you simply switch package type from "war" to "jar" in the Web module pom.xml (even if it does not make sens ), the artifact is automagically resolve from the project.

Test case

So here is the test case:
  • Create a Java project "ProjectJar" with a maven packaging of "jar"
  • Create a Dynamic Web Project "ProjectWar" with a maven packaging of "war"
  • Add "ProjectJar" to "ProjectWar" maven dependencies and check it is not resolved at all (neither from repository nor workspace)
  • Close "ProjectJar" and check it is resolved from repository (assuming you mvn-installed ProjectJar)
  • Re-open the project and switch ProjectWar packaging from "war" to "jar" in its pom.xml
  • Check the dependency resolves from workspace!
There is obviously an issue with handling of "war" projects combined with facets...

Criticity

As of me, this bug is a really serious one. Working on a Web project using multiple artifacts/Eclipse project makes me opening, closing and installing artifacts all the time in order to make the web-app project compile with latest changes from depending modules. A bug fix would be truly appreciated . Please ask if further test is needed.
Hide
Eugene Kuleshov added a comment -

Oliver, can you please attach your test projects to this issue. Thanks.

Show
Eugene Kuleshov added a comment - Oliver, can you please attach your test projects to this issue. Thanks.
Hide
Olivier LE MERDY added a comment - - edited

This file contains two Eclipse projects:

  • TestJar (packaged as "jar")
  • TestWar (packaged as "war") depending on the first

Import these trwo projects into your workspace. TestWar should not compile and TestJar should not be included in its Maven depencies.
Mvn-install the two projects thanks to the parent pom and then close TestJar. TestWar should now resolve TestJar from repository and compile.
Reopen TestJar and change packaging from "war" to "jar" in TestWar pom.xml. TestWar should now resolve TestJar from workspace!

This last fact signifies you can work almost normally by changing the Web modules from "war" to another type of packaging but this workaround is really dangerous as you could put an incorrectly typed pom.xml in your control version system and generate bad applications.

Show
Olivier LE MERDY added a comment - - edited This file contains two Eclipse projects:
  • TestJar (packaged as "jar")
  • TestWar (packaged as "war") depending on the first
Import these trwo projects into your workspace. TestWar should not compile and TestJar should not be included in its Maven depencies. Mvn-install the two projects thanks to the parent pom and then close TestJar. TestWar should now resolve TestJar from repository and compile. Reopen TestJar and change packaging from "war" to "jar" in TestWar pom.xml. TestWar should now resolve TestJar from workspace! This last fact signifies you can work almost normally by changing the Web modules from "war" to another type of packaging but this workaround is really dangerous as you could put an incorrectly typed pom.xml in your control version system and generate bad applications.
Hide
Holger Brands added a comment -

We've also run into this issue, now.
We want to integrate a maven project with packaging war with Eclipse dynamic web project.
As the last comment states, when you change packaging in the pom.xml from war to jar, the dependencies are resolved from workspace.
(with packaging war not).

But, we also want to use the "Run on Server" feature of WTP, so we'd like to publish the project via WTP to the configured tomcat instance.
But even if the dependencies are resolved from workspace by changing war to jar packaging, these dependencies are not published by WTP
to the server.
I have to close all dependent projects such that the dependencies are resolved as jar files. Only in this case, the dependency jars are deployed by WTP.

Show
Holger Brands added a comment - We've also run into this issue, now. We want to integrate a maven project with packaging war with Eclipse dynamic web project. As the last comment states, when you change packaging in the pom.xml from war to jar, the dependencies are resolved from workspace. (with packaging war not). But, we also want to use the "Run on Server" feature of WTP, so we'd like to publish the project via WTP to the configured tomcat instance. But even if the dependencies are resolved from workspace by changing war to jar packaging, these dependencies are not published by WTP to the server. I have to close all dependent projects such that the dependencies are resolved as jar files. Only in this case, the dependency jars are deployed by WTP.
Hide
Matthew Lieder added a comment -

Holger, we also have run across that issue. Until m2eclipse fixes it, our current work-around is to create source links (Project Properties -> Java Build Path -> Source -> Link Source) to the dependency projects. That does the trick pretty nicely.

Show
Matthew Lieder added a comment - Holger, we also have run across that issue. Until m2eclipse fixes it, our current work-around is to create source links (Project Properties -> Java Build Path -> Source -> Link Source) to the dependency projects. That does the trick pretty nicely.
Hide
Mark Hewett added a comment -

The WTP integration article on the Wiki (http://docs.codehaus.org/display/M2ECLIPSE/Integration+with+WTP) shows what may be the best solution at the moment - adding a J2EE Module Dependency entry for the missing projects. This should get WTP to deploy the dependent projects.

Show
Mark Hewett added a comment - The WTP integration article on the Wiki (http://docs.codehaus.org/display/M2ECLIPSE/Integration+with+WTP) shows what may be the best solution at the moment - adding a J2EE Module Dependency entry for the missing projects. This should get WTP to deploy the dependent projects.
Hide
Matthew Lieder added a comment -

Unfortunately my dependency projects don't show on that list, and there's no "Add Project" button :/

Show
Matthew Lieder added a comment - Unfortunately my dependency projects don't show on that list, and there's no "Add Project" button :/
Hide
Michael Reardon added a comment -

Also the J2EE Module Dependencies workaround from the Wiki, does not work for Eclipse features that do not use WTP. For example, launching JUnits.

Show
Michael Reardon added a comment - Also the J2EE Module Dependencies workaround from the Wiki, does not work for Eclipse features that do not use WTP. For example, launching JUnits.
Hide
Igor Fedorenko added a comment -

fixed. workspace dependencies should resolve properly now and wtp's "j2ee module dependencies" should be updated automatically.

Show
Igor Fedorenko added a comment - fixed. workspace dependencies should resolve properly now and wtp's "j2ee module dependencies" should be updated automatically.
Hide
Sei Syvalta added a comment - - edited

I'm still seeing this bug. I'll attach a stripped out version from Oliver's test case.

How to reproduce:
1. extract the zip
2. run mvn eclipse:m2eclipse in TestJar
3. run mvn -Dwtpversion="2.0" eclipse:m2eclipse in TestWar
4. import projects to eclipse
5. result: build errors in TestWar: it can't find class Foo (which is in TestJar)

Reopening and cleaning the projects doesn't help. If I turn off workspace resolution, the project builds fine in eclipse. Am I doing something wrong or should this work?

Edit: I'm using m2eclipse 0.9.4.20080521-2330 and Eclipse 3.3.2 with latest patches available from update site. Not sure if this has effect, but I tested with both embedded installation and Maven 2.0.9.

Edit2: Added wtpversion to TestWar.

Additionally, I see the following exception in error log:
java.lang.NullPointerException
at org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent.setReferences(VirtualComponent.java:356)
at org.maven.ide.eclipse.wtp.WTPProjectConfigurator.setModuleDependencies(WTPProjectConfigurator.java:215)
at org.maven.ide.eclipse.wtp.WTPProjectConfigurator.mavenProjectChanged(WTPProjectConfigurator.java:93)
at org.maven.ide.eclipse.project.configurator.AbstractProjectConfigurator.mavenProjectChanged(AbstractProjectConfigurator.java:50)
at org.maven.ide.eclipse.internal.project.ProjectConfigurationManager.mavenProjectChanged(ProjectConfigurationManager.java:501)
at org.maven.ide.eclipse.internal.project.MavenProjectManagerImpl.notifyProjectChangeListeners(MavenProjectManagerImpl.java:671)
at org.maven.ide.eclipse.internal.project.MavenProjectManagerImpl.refresh(MavenProjectManagerImpl.java:382)
at org.maven.ide.eclipse.internal.project.MavenProjectManagerRefreshJob.run(MavenProjectManagerRefreshJob.java:77)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Edit3: facets seem to get added ok.

Show
Sei Syvalta added a comment - - edited I'm still seeing this bug. I'll attach a stripped out version from Oliver's test case. How to reproduce: 1. extract the zip 2. run mvn eclipse:m2eclipse in TestJar 3. run mvn -Dwtpversion="2.0" eclipse:m2eclipse in TestWar 4. import projects to eclipse 5. result: build errors in TestWar: it can't find class Foo (which is in TestJar) Reopening and cleaning the projects doesn't help. If I turn off workspace resolution, the project builds fine in eclipse. Am I doing something wrong or should this work? Edit: I'm using m2eclipse 0.9.4.20080521-2330 and Eclipse 3.3.2 with latest patches available from update site. Not sure if this has effect, but I tested with both embedded installation and Maven 2.0.9. Edit2: Added wtpversion to TestWar. Additionally, I see the following exception in error log: java.lang.NullPointerException at org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent.setReferences(VirtualComponent.java:356) at org.maven.ide.eclipse.wtp.WTPProjectConfigurator.setModuleDependencies(WTPProjectConfigurator.java:215) at org.maven.ide.eclipse.wtp.WTPProjectConfigurator.mavenProjectChanged(WTPProjectConfigurator.java:93) at org.maven.ide.eclipse.project.configurator.AbstractProjectConfigurator.mavenProjectChanged(AbstractProjectConfigurator.java:50) at org.maven.ide.eclipse.internal.project.ProjectConfigurationManager.mavenProjectChanged(ProjectConfigurationManager.java:501) at org.maven.ide.eclipse.internal.project.MavenProjectManagerImpl.notifyProjectChangeListeners(MavenProjectManagerImpl.java:671) at org.maven.ide.eclipse.internal.project.MavenProjectManagerImpl.refresh(MavenProjectManagerImpl.java:382) at org.maven.ide.eclipse.internal.project.MavenProjectManagerRefreshJob.run(MavenProjectManagerRefreshJob.java:77) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) Edit3: facets seem to get added ok.
Hide
Sei Syvalta added a comment -

Test case, see my comment.

Show
Sei Syvalta added a comment - Test case, see my comment.
Hide
Igor Fedorenko added a comment -

Bugittaa, Maven Projects import wizard (File->Import->General->Maven Projects) is the only supported way to import new WAR projects into m2eclipse and I verified that it works for your test projects. Please open new issue report if you still have problems after using this import wizard.

Show
Igor Fedorenko added a comment - Bugittaa, Maven Projects import wizard (File->Import->General->Maven Projects) is the only supported way to import new WAR projects into m2eclipse and I verified that it works for your test projects. Please open new issue report if you still have problems after using this import wizard.
Hide
Igor Fedorenko added a comment -

Bugittaa, to clarify, you do not need to use maven-eclipse-plugin, with m2eclipse 0.9.4 everything should work out of the box, so correct/supported steps to import your test projects are

  1. extract the zip
  2. import proecjst to eclipse using Maven Projects import wizard (File->Import->General->Maven Projects)

Results, TestWar has proper j2ee module dependency on TestJar and both projects build without errors in eclipse.

Show
Igor Fedorenko added a comment - Bugittaa, to clarify, you do not need to use maven-eclipse-plugin, with m2eclipse 0.9.4 everything should work out of the box, so correct/supported steps to import your test projects are
  1. extract the zip
  2. import proecjst to eclipse using Maven Projects import wizard (File->Import->General->Maven Projects)
Results, TestWar has proper j2ee module dependency on TestJar and both projects build without errors in eclipse.
Hide
Andrius Kurtinaitis added a comment -

is the fixed version available online?
my eclipse uses this update site: http://m2eclipse.sonatype.org/update/
it has the version 0.9.3.20080421-2352
and says there are no updates. Is it ok? Is it the same as 0.9.4?

Show
Andrius Kurtinaitis added a comment - is the fixed version available online? my eclipse uses this update site: http://m2eclipse.sonatype.org/update/ it has the version 0.9.3.20080421-2352 and says there are no updates. Is it ok? Is it the same as 0.9.4?
Hide
Igor Fedorenko added a comment -

m2eclipse 0.9.4 weekly builds are available from http://m2eclipse.sonatype.org/update-dev/ update site

Show
Igor Fedorenko added a comment - m2eclipse 0.9.4 weekly builds are available from http://m2eclipse.sonatype.org/update-dev/ update site
Hide
Sei Syvalta added a comment -

Thanks Igor. I tried maven project import. Some findings:

  • project references work now but I got one missing dependency (it's a provided dependency defined in a parent pom)
  • warSourceDirectory defined for war-plugin (in parent pom) isn't used, it's uses the default /src/main/webapp
  • I can't specify outputDirectory (I would like to use build instead of target-eclipse)

For the first thing listed, I'll have to investigate more. For the last two, should I submit a feature requests (checked JIRA and didn't find anything related)?

Show
Sei Syvalta added a comment - Thanks Igor. I tried maven project import. Some findings:
  • project references work now but I got one missing dependency (it's a provided dependency defined in a parent pom)
  • warSourceDirectory defined for war-plugin (in parent pom) isn't used, it's uses the default /src/main/webapp
  • I can't specify outputDirectory (I would like to use build instead of target-eclipse)
For the first thing listed, I'll have to investigate more. For the last two, should I submit a feature requests (checked JIRA and didn't find anything related)?
Hide
Igor Fedorenko added a comment -

yes, please open separate jira for each problem. sample project and steps to reproduce will let us provide fixes faster.

Show
Igor Fedorenko added a comment - yes, please open separate jira for each problem. sample project and steps to reproduce will let us provide fixes faster.
Hide
Michael Figuiere added a comment -

As I can see, in versions 0.9.5 and 0.9.7.200810211352 (last one available in dev update site as of today), this issue is still here :

In any project, if I set packaging option to "war" in the pom.xml, none of the dependencies available in the workspace are resolved. If I change the packaging option to "jar", all of them are correctly resolved.

Show
Michael Figuiere added a comment - As I can see, in versions 0.9.5 and 0.9.7.200810211352 (last one available in dev update site as of today), this issue is still here : In any project, if I set packaging option to "war" in the pom.xml, none of the dependencies available in the workspace are resolved. If I change the packaging option to "jar", all of them are correctly resolved.
Hide
Eugene Kuleshov added a comment -

Michael, after changing packaging in your pom.xml you may have to run Maven / Update project configuration in order to align project properly with WTP. You also need to make sure that m2eclipse WTP integration feature is installed.

Show
Eugene Kuleshov added a comment - Michael, after changing packaging in your pom.xml you may have to run Maven / Update project configuration in order to align project properly with WTP. You also need to make sure that m2eclipse WTP integration feature is installed.
Hide
Antony Stubbs added a comment -

I can confirm that I am quite successfully deploying a war project along with it's dependency which is an open project in my workspace - i.e. works for me

Show
Antony Stubbs added a comment - I can confirm that I am quite successfully deploying a war project along with it's dependency which is an open project in my workspace - i.e. works for me
Hide
Ryan Ackley added a comment -

Are you running Ganymede? I'm seeing this problem in Ganymede with the latest version.

If I go to Project->Properties->Java EE Module Dependencies and manually check the projects, it works. The "Maven Dependencies" dependency shows up in this list but somehow it's not being linked to the projects at runtime. I have to manually re-check these each time I do "Update Project Configuration" or "Update Dependencies".

Show
Ryan Ackley added a comment - Are you running Ganymede? I'm seeing this problem in Ganymede with the latest version. If I go to Project->Properties->Java EE Module Dependencies and manually check the projects, it works. The "Maven Dependencies" dependency shows up in this list but somehow it's not being linked to the projects at runtime. I have to manually re-check these each time I do "Update Project Configuration" or "Update Dependencies".
Hide
Antony Stubbs added a comment -

omg - a year later and i hit the same issue! (a year after my original issue - MNGECLIPSE-446).
I had to manually add the transitive dependency to the project under Java EE Modules as Ryan described.

Show
Antony Stubbs added a comment - omg - a year later and i hit the same issue! (a year after my original issue - MNGECLIPSE-446). I had to manually add the transitive dependency to the project under Java EE Modules as Ryan described.
Hide
Eugene Kuleshov added a comment -

Antony, this is not enough information. Please open new jira issue, specify version of m2eclipse, attach your Eclipse configuration details from Help / About Eclipse SDK / Configuration Details and test project that would allow us to reproduce. Please also note that there is significant improvements in 0.9.7 dev builds related to Java EE / WTP support, so you may want to try it first.

Show
Eugene Kuleshov added a comment - Antony, this is not enough information. Please open new jira issue, specify version of m2eclipse, attach your Eclipse configuration details from Help / About Eclipse SDK / Configuration Details and test project that would allow us to reproduce. Please also note that there is significant improvements in 0.9.7 dev builds related to Java EE / WTP support, so you may want to try it first.
Hide
Antony Stubbs added a comment -

oh, no believe me i know that's not enough information - my intention was not to fix it, just to raise suspicion And to respond to Ryan's comment about my comment. I'll try the next version first before I try reproducing it in a test project.

Show
Antony Stubbs added a comment - oh, no believe me i know that's not enough information - my intention was not to fix it, just to raise suspicion And to respond to Ryan's comment about my comment. I'll try the next version first before I try reproducing it in a test project.
Hide
Stefan Bley added a comment -

In my case, the workspace resolution of a JAR dependency in a WAR project did not work because there had been maven-eclipse-plugin settings in the pom (i.e. project facets, wtp version etc.)
When I removed these settings from the pom and re-imported the project through the wizard (first clean it thoroughly), the workspace resolution worked and the dependency was shown under "Web App Libraries".

Show
Stefan Bley added a comment - In my case, the workspace resolution of a JAR dependency in a WAR project did not work because there had been maven-eclipse-plugin settings in the pom (i.e. project facets, wtp version etc.) When I removed these settings from the pom and re-imported the project through the wizard (first clean it thoroughly), the workspace resolution worked and the dependency was shown under "Web App Libraries".

People

Vote (24)
Watch (24)

Dates

  • Created:
    Updated:
    Resolved: