1

I'm having an issue with an OSGi bundle project as follows:

I have classes that require the use of JDOM. I currently have the project working fine when I deploy JDOM as a separate bundle. That bundle exports the following packages:

org.jdom,version=1.0.0
org.jdom.adapters,version=1.0.0
org.jdom.filter,version=1.0.0
org.jdom.input,version=1.0.0
org.jdom.output,version=1.0.0
org.jdom.transform,version=1.0.0
org.jdom.xpath,version=1.0.0

Now I want to change the project such that I include JDOM as an Embed-dependency. To do that I add the dependency to my pom files and set the following in the maven-bundle-plugin configuration:

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
    <instructions>
        <Bundle-SymbolicName>com.qnx.aem.cloudsite-bundle</Bundle-SymbolicName>
            <Embed-Transitive>true</Embed-Transitive>
            <Embed-Dependency>jdom</Embed-Dependency>
    </instructions>
</configuration>
</plugin>

After this when I look at our projects bundle manifest I see a bunch of new Import Packages requiring dependencies of the JDOM jar: jaxen, xerces, etc.

How on earth did the previously deployed OSGi bundle of JDOM resolve these same dependencies? They were never listed in the bundles Import Packages? Furthermore if I try to include these as dependencies of the project and embed them it just compounds the problem. Help!

  • I guess those packages were imported in the original jdom jar with the "resolution:=optional" directive or they were not imported at all. Could you please provide a link to the jdom jar you used? – Balazs Zsoldos Sep 25 '14 at 18:00
  • Sure I used this JAR: http://mvnrepository.com/artifact/jdom/jdom/1.0 – The Doctor 'X' Sep 26 '14 at 18:39
  • I used this bundle version of JDOM: http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.jdom&version=1.0.0 – The Doctor 'X' Sep 26 '14 at 18:40

1 Answers1

0

The bundle that you use imports those packages with "resolution:=optional". Due to this reason, the original bundle could have been resolved without having the dependencies in the OSGi container.

I guess that When you embedded the dependency, maven-bundle-plugin analyzed the bytecode of the embedded dependency instead of the MANIFEST header. The packages are imported without the "resolution:=optional" directive. You can specify it again in the configuration of maven-bundle-plugin like this:

<Import-Package>
    org.jaxen.*;resolution:=optional,
    *
</Import-Package>

Question is: Why do you want to embed a jar that is already a working OSGi bundle? It is better to use it as it is.

Balazs Zsoldos
  • 6,036
  • 2
  • 23
  • 31