unsatisfied AEM components because of duplicate package names
Today, I had an issue, where some of my AEM components just would not start. They had “unsatisfied” service references, but the referenced services were up and running.
After a lot of searching and thanks to this blog post, I finally found out that the actual problem was that the referenced services’s package name was identical to a package name in my component’s bundle.
So what happened?
Let’s say my Interface was set up like this:
- bundle name: codeflair-blog-api
- Interface name: ch.codeflair.blog.api.BlogInterface.java
Package ch.codeflair.blog.api.* was exported and therefore the interface was made available by the bundle.
My implementing class ch.codeflair.blog.impl.BlogInterface.java was set up in a different bundle, let’s say codeflair-core-impl. In this bundle there was another (completely unrelated component) which implemented interface ch.codeflair.blog.api.ConflictingInterface.java in bundle codeflair-core-api.
codeflair-core-api also exported ch.codeflair.blog.api.*, and because the bundle also had a dependency on codeflair-blog-api, all classes from package ch.codeflair.blog.api in codeflair-blog-api were copied to bundle codeflair-core-api and also made available in that bundle. Now our ch.codeflair.blog.api.BlogInterface.java is availabe in two different bundles, so an adapter factory will not recognize that ch.codeflair.blog.impl.BlogInterface.java actually implements ch.codeflair.blog.api.BlogInterface.java from codeflair-blog-api.
So the bottom line is: choose a good package struckter und really make sure a package is neever user in two different bundles!