How to install and run osgi package in apache karaf

I have a simple question. I followed this tutorial and created the HelloWorld osgi package. How can I install and run this package using apache Karaf ? How can I access a set using the osgi: install command?

thanks.

+7
source share
3 answers

Ok, this is another question, but here goes:

You are pretty much on the right track, I tested the one you pointed out in the Karaf developer guide (second mvn call). The documentation is not entirely correct, I needed to change two things:

  • The version is disabled, 2.2.5 works (on my machine), changing it to 2.2.8 seems to help.
  • The name of the package is com.mycompany.package. Since the package is a keyword, this will not compile, so I changed it to com.mycompany.bundle.

So my archetype command:

mvn archetype:generate \ -DarchetypeGroupId=org.apache.karaf.archetypes \ -DarchetypeArtifactId=karaf-bundle-archetype \ -DarchetypeVersion=2.2.8 \ -DgroupId=com.mycompany \ -DartifactId=com.mycompany.bundle \ -Dversion=1.0-SNAPSHOT \ -Dpackage=com.mycompany.bundle 

Then I went into the new project folder: com.mycompany.bundle:

 cd com.mycompany.bundle 

And installing mvn:

 mvn install 

Then in the "target /" folder there is a jar file that you can install in the Karaf installation, as I said.

Creating a package in Eclipse

  • New β†’ Plugin project β†’ Choose a name β†’ check options β†’ you can use the template if you want.

  • Select a project β†’ Export β†’ Plugin / Snippet β†’ Select a folder

Here is your jar file.

+5
source

You can simply drop the package into the deploy directory, and Karaf just notices and installs it.

+6
source

Frank's answer helped me pretty quickly:
I created a set with this archetype:

 mvn archetype:generate \ -DarchetypeGroupId=org.apache.karaf.archetypes \ -DarchetypeArtifactId=karaf-bundle-archetype \ -DarchetypeVersion=2.2.8 \ -DgroupId=com.mycompany \ -DartifactId=com.mycompany.bundle \ -Dversion=1.0-SNAPSHOT \ -Dpackage=com.mycompany.bundle 
Then i did a mvn eclipse:eclipse and mvn install . After copying the generated jar into the deploy directory of my running JBoss Fuse server it printed "Starting the bundle". :-)

+1
source

All Articles