简体   繁体   中英

how to install and run osgi bundle in apache karaf

I have a simple question. I followed this tutorial and created a HelloWorld osgi bundle. How can i install and start this bundle using apache Karaf ? How can i refer to the bundle using the osgi:install command?

thank you.

您可以将捆绑包放入“deploy”目录,而Karaf只是注意并安装它。

Ok, that is another question, but here goes:

You're pretty much on the right track, I've tested the one in the Karaf developers guide you linked to (the second mvn call). The documentation isn't quite correct, I needed to change two things:

  • The version is off, 2.2.5 does work (on my machine), changing it to 2.2.8 seemed to help.
  • The package name is com.mycompany.package. As package is a keyword, that won't compile, so I've changed it to com.mycompany.bundle.

So my archetype command was:

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 entered the newly made project folder: com.mycompany.bundle:

cd com.mycompany.bundle

And a mvn install:

mvn install

Then there is a jar file in the 'target/' folder, which you can install into the Karaf installation as I said before.

Creating a bundle in Eclipse

  • New -> Plugin Project -> Choose a name -> check the parameters -> you can use a template if you like.

  • Select your project -> Export -> Plugin/Fragment -> Choose a folder

There's your jar file.

Frank's answer helped me quite fast:
I created a bundle 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". :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM