Home » maven3 » Adding Third Party Jars To An OSGI Bundle

Adding Third Party Jars To An OSGI Bundle

Sign up for OpenShift Account

Blog Stats

  • 238,303 hits

My Tweets


Few days back I was writing a Spring Roo add-on(an OSGI bundle) which required me to add some external 3rd party jars to the OSGI bundle pom.xml file. I am not very well verse with OSGI so it took me some time to figure out how to add 3rd party jars to an OSGI bundle. In this short blog post I am sharing the recipe to add third part jars.

The exception that you get when OSGI bundle is not able to find the dependency is like this.

org.osgi.framework.BundleException: Unresolved constraint com.shekhar.roo.addon [66]: Unable to resolve 66.0: missing requirement [66.0] package; (package=com.shekhar.utils)

To solve this error you need to add Embed-Dependency tag to your maven bundle plugin as shown below. The example shows that I need to add commons-io and utils jar to my OSGI bundle. To get more information about Embed-Dependency tag and maven bundle plugin please refer to the documentation.

<plugin>
	<groupId>org.apache.felix</groupId>
	<artifactId>maven-bundle-plugin</artifactId>
	<version>2.3.4</version>
	<extensions>true</extensions>
	<configuration>
		<instructions>
		<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
		<Bundle-Copyright>Copyright Shekhar Gulati. All Rights Reserved.</Bundle-Copyright>
		<Bundle-DocURL>${project.url}</Bundle-DocURL>
		utils,jsch,commons-io;scope=compile|runtime;inline=false</Embed-Dependency>
		</instructions>
		<remoteOBR>true</remoteOBR>
	</configuration>
</plugin>
About these ads

2 Comments

  1. [...] Adding Third Party Jars in an OSGI bundle. I have blogged this at http://whyjava.wordpress.com/2012/01/02/adding-third-party-jars-to-an-osgi-bundle/. [...]

  2. May I just say that after finding Adding Third Party Jars To An OSGI Bundle « Shekhar
    Gulati : OpenShift Evangelist, Software Developer, Writer, and Speaker on PHP-Nuke, what a comfort to
    come across a person who finally understands what they’re talking about when it comes to this. You seriously grasp how to bring a problem to light and make it important. A lot more people need to look at this and understand this perspective. It’s surprising you’re not more well-known, because you most certainly possess the gift.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 265 other followers

%d bloggers like this: