Tag Archives: Maven

Maven, Eclipse, WTP and project dependencies

If you are working with Maven, Eclipse and WTP, you can encounter different problems.

One of them is connected to project dependencies. Imagine that you have an in-house library A and a web application B that depends on A. Sometimes, when I run the webapp in a server using WTP, it can not find classes (or resources) from B. It’s quite confusing if you get a ClassNotFoundException even though the class is apparently there. It happens only if you are using m2eclipse extras. If you have different configuration this solution will not probably help you.

Ok, so you have m2extras and you are getting ClassNotFoundException. What next? You have to check file A/.settings/org.eclipse.wst.common.component (I use the Navigator View to access the file)

If you see something like this

<?xml version="1.0" encoding="UTF-8"?> 
<project-modules id="moduleCoreId" project-version="1.5.0"> 
  <wb-module deploy-name="module-a"> 
  <wb-resource deploy-path="/" source-path="/src"/> 
  </wb-module> 
</project-modules> 

you have found the issue. The source-path attribute is wrong. It’s necessary to set the value to /src/main/java. Sometimes the path is not just wrong, but it’s completely missing. In such case just add a new line with corresponding configuration and everything should work as expected.