Issue Details (XML | Word | Printable)

Key: MNGECLIPSE-438
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Igor Fedorenko
Reporter: Mark Hewett
Votes: 24
Watchers: 22
Operations

If you were logged in you would be able to see more operations.
Maven Integration for Eclipse

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

Created: 12/Nov/07 10:36 PM   Updated: 25/Nov/08 09:36 AM
Component/s: WTP integration
Affects Version/s: 0.0.12
Fix Version/s: 0.9.4

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive m2eclipse-bug.zip (14 kB)
2. Zip Archive m2eclipse-test-packaging.zip (9 kB)
3. Zip Archive wtp-problem.zip (4 kB)

Environment: eclipse europa jee fall (3.3.1), windows xp
Issue Links:
Duplicate
 
Related


 Description  « Hide
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>



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Mark Hewett added a comment - 13/Nov/07 09:17 AM
This "issue" seems to be by design per MNGECLIPSE-105.

Olivier LE MERDY added a comment - 08/Jan/08 12:05 PM - 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.


Eugene Kuleshov added a comment - 08/Jan/08 12:15 PM
Oliver, can you please attach your test projects to this issue. Thanks.

Olivier LE MERDY added a comment - 08/Jan/08 01:31 PM - 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.


Holger Brands added a comment - 16/Mar/08 11:03 AM
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.


Matthew Lieder added a comment - 18/Mar/08 10:29 AM
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.

Mark Hewett added a comment - 18/Mar/08 04:03 PM
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.

Matthew Lieder added a comment - 18/Mar/08 04:16 PM
Unfortunately my dependency projects don't show on that list, and there's no "Add Project" button :/

Michael Reardon added a comment - 15/Apr/08 06:06 PM
Also the J2EE Module Dependencies workaround from the Wiki, does not work for Eclipse features that do not use WTP. For example, launching JUnits.

Igor Fedorenko added a comment - 02/May/08 10:33 PM
fixed. workspace dependencies should resolve properly now and wtp's "j2ee module dependencies" should be updated automatically.

Bugittaa Pahasti added a comment - 22/May/08 03:35 AM - 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.


Bugittaa Pahasti added a comment - 22/May/08 03:36 AM
Test case, see my comment.

Igor Fedorenko added a comment - 22/May/08 09:04 AM
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.

Igor Fedorenko added a comment - 22/May/08 09:07 AM
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.


Andrius Kurtinaitis added a comment - 22/May/08 09:24 AM
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?

Igor Fedorenko added a comment - 22/May/08 09:27 AM
m2eclipse 0.9.4 weekly builds are available from http://m2eclipse.sonatype.org/update-dev/ update site

Bugittaa Pahasti added a comment - 23/May/08 12:54 AM
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)?


Igor Fedorenko added a comment - 23/May/08 07:26 AM
yes, please open separate jira for each problem. sample project and steps to reproduce will let us provide fixes faster.

Michael Figuiere added a comment - 30/Oct/08 10:23 AM
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.


Eugene Kuleshov added a comment - 30/Oct/08 10:35 AM
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.

Antony Stubbs added a comment - 30/Oct/08 11:14 AM
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

Ryan Ackley added a comment - 13/Nov/08 11:17 PM
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".


Antony Stubbs added a comment - 25/Nov/08 08:52 AM
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.

Eugene Kuleshov added a comment - 25/Nov/08 09:07 AM
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.

Antony Stubbs added a comment - 25/Nov/08 09:36 AM
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.