Missing OSGI Dependencies

nickt39971962

04-09-2019

When adding a new dependency in the POM file of an OSGI bundle (which is deployed inside an AEM package to CRX) I will often see a number of unresolved dependencies in the OSGI console. The bundle will fail to activate.

Example:

org.jaxen.dom -- Cannot be resolved

org.jaxen.dom4j -- Cannot be resolved

org.jaxen.jdom -- Cannot be resolved

org.jaxen.pattern -- Cannot be resolved

org.jaxen.saxpath -- Cannot be resolved

org.jdom -- Cannot be resolved

org.jdom.input -- Cannot be resolved

org.jdom.output -- Cannot be resolved

How can I debug this type of problem? How can I understand why those dependencies are required yet cannot be resolved?

I can see in the POM that the bundle has been configured as follows:

<plugin>

                <groupId>org.apache.felix</groupId>

                <artifactId>maven-bundle-plugin</artifactId>

                <configuration>

                    <instructions>

                        <Bundle-Activator>com.mycompany.aem.Activator</Bundle-Activator>

                        <Export-Package>

                            com.mycompany.aem.*

                        </Export-Package>

                        <Sling-Model-Packages>

                            com.mycompany.aem.components.page,

                            com.mycompany.aem.models,

                            com.mycompany.aem.helper

                        </Sling-Model-Packages>

                        <Include-Resource>{maven-resources}</Include-Resource>

                        <Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>

                        <Embed-Transitive>true</Embed-Transitive>

                        <Import-Package>

                            android.util.*;resolution:=optional,

                            javax.validation.*;resolution:=optional,

                            org.apache.axiom.*;resolution:=optional,

                            org.apache.cxf.*;resolution:=optional,

                            !com.sun.msv.*;resolution:=optional,

                            !com.sun.xml.bind.marshaller.*;resolution:=optional,

                            !com.sun.xml.fastinfoset.stax.*;resolution:=optional,

                            !net.sf.cglib.*;resolution:=optional,

                            !org.apache.aries.*;resolution:=optional,

                            org.apache.axiom.*;resolution:=optional,

                            org.apache.mina.*;resolution:=optional,

                            org.osgi.service.blueprint.*;resolution:=optional,

                            !org.relaxng.*;resolution:=optional,

                            !org.springframework.*;resolution:=optional,

                            !javax.resource.*;resolution:=optional,

                            !javax.xml.ws.spi.http.*;resolution:=optional,

                            !com.sun.*;resolution:=optional,

                            sun.*;resolution:=optional,

                            org.apache.*;resolution:=optional,

                            org.jvnet.*;resolution:=optional,

                            *

                        </Import-Package>

                    </instructions>

                </configuration>

            </plugin>

Accepted Solutions (1)

Accepted Solutions (1)

anujg3325839

04-09-2019

All these dependencies should already present if not shipped with the bundle jar/package. you can check the stdout log to see the details on why these dependencies are not resolved. in case these dependencies are part of some other bundle package, please ensure the other bundle should get started first, you can control it via start-up level of the bundle.

Answers (1)

Answers (1)

nickt95164926

05-09-2019

The code compiles successfully with Maven. The issues arise when the bundle is activated in Felix.

When I look at the contents of the bundle zip file, some of those dependencies: org.jaxen and org.jdom are not present and with the full maven output using -X I see no errors or warnings about them.

However, for some reason, when running in Felix these dependencies are required and cannot be resolved.