0

I Have Created a BndTools OSGi project that generates a .jar file.Now i want the BundleContext of that jar in my main project i.e. Dynamic Web Project (.war File). Dynamic web Project doesn't contain bnd.bnd file.So i can't inject that jar's dependency.

Are there any ways by which i can achieve this.

Kishor Sawant
  • 88
  • 1
  • 10
  • Can you please clarify your question? Jars don't have a BundleContext. What are you actually trying to do? – Neil Bartlett Dec 24 '14 at 15:46
  • I have One .war file. From that war file i just want to call to two separate .jar files.Now problem is, i Have created those .jar files using Bundle OSGi project(eclipse plugin), so those project has bnd.bnd files. But the project from which i have created .war file is dynamic Web project. so My Question is how to call function inside jar from function inside war file. – Kishor Sawant Dec 25 '14 at 05:19

1 Answers1

2

This can be accomplished two ways.

Quick and dirty way

  1. Create dynamic web project
  2. Right click web project > Choose Properties menu
  3. Click on Deployment Assembly
  4. Click Add
  5. Select Project for assembly directive type
  6. Select the bndtools project
  7. Repeat for 2nd project you want
  8. Deploy this web project to server or export war and notice that the output of the

Note this jar will only create the classes and no other resources that are usually created by the bnd.bnd file (e.g. correct Manifest, other included resources)

Better and more correct way

  1. Deploy the 2 jar files created by bndtools to some artifact repository local or public
  2. Create a new maven project using war packaging (e.g. default web project archetype)
  3. Specify these two bndtools project jars as dependencies
  4. Install the m2e-wtp plugin from its updatesite for Eclipse (which imports maven war projects and automagically creates eclipse dynamic web projects with all dependency references setup)
  5. Import the maven web project using File > Import > existing maven project
  6. During import the m2e-wtp project configurator will be activated and the necessary settings for including your 2 bndproject jars as dependencies will be correctly setup
Community
  • 1
  • 1
gamerson
  • 5,220
  • 1
  • 28
  • 45