Eclipse maven-enabled web app references workspace projects, but those are not deployed when running Tomcat server
Asked Answered
I

1

7

I have a web application (Eclipse's Dynamic Web App) which uses Maven (m2e-wtp) for the build and dependencies management. This web app's POM references a few other projects in my workspace, which happen to be eclipse plugins built with maven as well (built using Tycho), and also other third party libraries which come from Maven's repository.

Everything works fine when I run maven from the CLI. All dependencies are included in the WEB-INF/lib directory just as expected.

The problem is when I attempt to run the project using Eclipse. I run the app in a configured Tomcat server inside Eclipse, but the referenced projects in my workspace are not added to the deployed war.

I tried adding them to the Deployment Assembly (under project preferences), and that works perfectly, but those settings get wiped out by m2e every time the maven configurations are updated. I read in a few places that we should not manually add entries there since all dependencies should be managed by m2e...

The question is: How to make Eclipse add the workspace project dependencies to the WEB-INF/lib of my web app when I run it from Eclipse?

I'm using Eclipse J2EE 4.3.1 (Kepler SR1).

I also tried right-clicking the project and selecting Export -> WAR file, but the exported WAR file doesn't include the referenced workspace projects either. I'm assuming the issue is affecting both cases.

This is extremely annoying ans is slowing me down quite a bit.. at this time I have to re-add the projects to the Deployment Assembly page several times a day to keep it going...

UPDATE: The workspace projects I added as dependencies in the POM appear in the list of Referenced Projects, under the project's properties. But when I expand the Maven Dependencies in the Project Explorer, the workspace project dependencies are missing from the list! Only the ones in the Maven repository show up. They local ones seem to be silently ignored...

Insignificant answered 23/12, 2013 at 20:34 Comment(3)
what scope are the dependencies in? It should be compile or runtime to be included in the war.Ammeter
I hand't actually added any explicit scope and I assumed it was in compile by default. I added a compile scope but I get the same results. Everything is fine in the workspace, and when I run a maven build, but if I start the web app from eclipse the referenced workspace projects are not included... I get a java.lang.NoClassDefFoundError when trying to use them.Insignificant
hi, have anyone managed to get this to work?Oakland
C
0

I had similar problem because I created the project outside eclipse, and them imported it. What worked for me was to add the right project facet: Project context menu -> properties -> Project Facets -> Dynamic Web Module (choose right version). I was using Eclipse ADT (version 4.2.0), but, to avoid having multiple installations, I use the same eclipse for Android and other kind of apps.

Chirm answered 31/1, 2014 at 17:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.