How do I get maven managed dependencies copied into war\web-inf\lib so I can run my GWT 2.0 app in debug mode within Eclipse?

20,607

Solution 1

Running the gwt:eclipse goal will copy the maven dependencies into war/WEB-INF/lib. See the Eclipse Configuration section of the Eclipse IDE Integration documentation of the Maven GWT plugin for more details. Also have a look at this answer about Maven GWT 2.0 and Eclipse.

Solution 2

You should install the m2eclipse plugin and use that to build your project within eclipse. This will invoke maven as an external tool from within eclipse.

Your maven project artifact type should be set to war, which will let maven discover the dependencies and bundle them.

See these links:

force Maven2 to copy dependencies into target/lib

http://maven.apache.org/plugins/maven-war-plugin/

http://maven.apache.org/plugins/maven-war-plugin/examples/rapid-testing-jetty6-plugin.html

Solution 3

a maven aware IDE (idea, eclipse, netbeans) should do this packaging automatically. maybe you:

  • forgot to enable maven import inside IDE?
  • did not add these dependencies to the pom.xml (so they aren't included in the 'mvn package' phase)
  • added wrong scope to dependency declaration (e.g. scope 'provided' or 'tested'), so they are ignored for runtime

Solution 4

If you have the packaging method in your pom.xml set to war it should copy runtime depdencies into target/war/WEB-INF/lib.

Or is your project to build something larger like an ear? If so you should probably split your pom.xml into multi-project format.

As for Eclipse, I'm not terribly familiar with it so I can't really help you there. Are you (or can you) run a maven target (like "install") when you do a run or debug?

Share:
20,607
Tony
Author by

Tony

Some guy...

Updated on September 16, 2020

Comments

  • Tony
    Tony over 3 years

    I am updating an existing project from GWT 1.5.2 to GWT 2.0.0. We use maven 2 to manage our dependencies and do all of our development in Eclipse 3.5.

    Because we use maven to manage our dependencies, I do not have all of those jars in the war\web-inf\lib directory as GWT specifies. Instead, they are in the maven repository, just where maven likes them. I have the project set up so that maven can successfully build and launch in either dev or web mode and the application runs correctly.

    The problem is that when I launch from Eclipse, I get a java.lang.NoClassDefFoundError. If I manually copy of my dependencies into war\web-inf\lib before launching, everything runs fine, but that doesn't lend itself to a long-term solution. First, if I check all of those jars into our version control, that will subvert much of the value we get from maven. As annoying as maven can be, ditching it is not the answer. Second, having developers manually copy them over every time they want to debug something is ridiculous.

    So can I get Eclipse to copy the dependencies into war\web-inf\lib before launching? Is there an alternate solution that I'm missing?

    Thanks,

    Tony