8
votes

I'm developing a web project using Eclipse Juno, Tomcat 7 and Maven 3 and have run into a strange problem.

I have a separate project where I compile some stuff and I pick that jar up in my web project as a dependency. So, the end result is one .war. Now, when I run this war in embedded Tomcat in Eclipse and hit the refresh button on my browser, Tomcat says it cannot find a path in that jar.

In the workspace WEB-INF/lib folder I find the myApplication-common-widgetset-0.0.11-20130926.124257-7.jar

In the Tomcat Deployment directory under wtpwebapps/myApplication/WEB-INF/lib I see myApplication-common-widgetset-0.0.11-SNAPSHOT.jar The strange thing is that the file under the Tomcat lib is 1kb large and the file in my workspace lib is ~22Mb.

I tried to copy the workspace jar to the Tomcat lib folder and everything works and run as a charm.

Updates:

  • When I run mvn tomcat:run from the command line in my workspace, everything works.
  • I "re-installed" both Eclipse (to Kepler, wiping everything, including workspace and home folders) and Tomcat 7. I still have the same issue.
  • Colleges tried fetching my project from SVN and ran it successfully, both with Eclipse and IntelliJ + Tomcat 7

What could have happened? Why is Eclipse embedded Tomcat not getting everything from the target directory?

1
You could try right-click on the Tomcat server in the Eclipse Servers view, and select "Clear working dir" or similar. I've seen similar weird stuff that was solved this way. - geert3
The clean working dir, clean tomcat, add/remove project does nothing for me the problem persists. - Gabriel Netto

1 Answers

0
votes

The issue I think you're facing is the reality that eclipse does not strictly honour the maven dependencies.

This has to do with the fact that eclipse does not defer to maven when building, deploying and running on tomcat. Eclipse will use your local workspace setup and will thus sometimes introduce a dependency tree that is different from maven.

From the information you've supplied it appears as if that workspace lib file is the one sourced from a maven repository and the one in embedded tomcat deployment directory is a jar that eclipse has built - I'm guessing here.

If that jar is from a workspace project you can try closing the project and letting eclipse find the jar from maven.

This issue with Eclipse and Maven is rather nebulous and so is difficult to figure out exactly what is going on in terms of dependencies so sorry I can't be of more help