My project P depends on dependency A which depends on dependency B. My project’s pom.xml file includes A as a dependency, and its jar is included in P’s classpath. However, there is a NoClassDefFoundError thrown at runtime of P, which stems from missing B jars.
Shouldn’t Maven have downloaded these dependencies automatically?
Unless B is an optional dependency of A, B should be a dependency of P with a “compile(*)” scope (see the table of Dependency Scope and read the note) and should thus be available at runtime.
Since you’re running the project under Eclipse, the class path is setup for you so I’ll exclude a mistake at this level. This leaves us with the case of the optional dependency.
PS: A very useful tool to investigate this kind of problem is
dependency:tree.