Skip to content

Maven compiler cannot resolve import

I’m trying to build multiple eclipse products with maven and tycho. I’m currently stuck on an issue, where a Bundle A is dependent on a class from Bundle B. Bundle B has a package structure similar to:


When I now try to build A I get a compile error that looks somewhat like this:

 import a.b.c.d.e.f.MyClass;
[ERROR] ^^^^^^^^^
[ERROR] The import a.b.c.d.e cannot be resolved

If you look closely, you see that Maven apparently tries to resolve the wrong package, since it only states it cannot resolve a.b.c.d.e while the class that is meant to be imported is actually in a.b.c.d.e.f.

Additionally, there are no classes present in a.b.c.d.e. I’ve tried both including a.b.c.d.e as an exported package in the Manifest, and removing it from that list, but neither did help.

What could be the issue here?


After running maven with very detailed logging, I double checked the arguments, that maven (tycho) was passing to the JDT compiler when compiling Bundle A. I noticed, that it was only passing a JAR that I added to Bundle B’s classpath.

I then noticed, that in the MANIFEST of Bundle B, where I specified the Bundle-Classpath, I had only The JAR on the classpath. I previously thought the classes of the bundle itself would be added per default, but after adding ,. to the Bundle-Classpath property the build worked again.

If you want to read more about it, THIS POST pointed me in the right direction.