0

I have a bundle:

<groupId>com.helloworld</groupId>
<artifactId>Helloworld</artifactId>
<version>1.0.0-SNAPSHOT</version>

Previously, the bundle and OSGi container(FUSE ESB Enterprise) are at the same machine. I use the following command to install it from local maven repository:

FuseESB:karaf@root> install file:/home/li/.m2/repository/com/helloworld/Helloworld/1.0.0-SNAPSHOT/Helloworld-1.0.0-SNAPSHOT.jar

Now the bundle and OSGi container are at different machine:

bundle in a machine where IP is 192.168.122.22

How can I install this bundle remotely?

Li'
  • 3,133
  • 10
  • 34
  • 51

2 Answers2

1

Notice that the argument to the install command is a URL. So you can install from any URL for which you have a URL handler available. For example:

install http://www.example.com/helloworld-1.0.jar

Neil Bartlett
  • 23,743
  • 4
  • 44
  • 77
  • I have updated my question. Is it possible to run a bundle outside the container? – Li' May 30 '13 at 17:11
1

For Fuse ESB or more general for Apache Karaf based servers you have the pax url mvn uri prefix. This allows to install bundles from mvn repositories. I propose to always use this uri instead of the file one. In your case the command would be:

install mvn:com.helloworld/Helloworld/1.0.0-SNAPSHOT

This uri is even a little smaller than the file based one. The big adavantage though is that you have the full mvn resolution available. So this above url will work for bundles from your local maven repo but also from maven central.

Of course you typically will not deploy your own artifacts to maven central. So if you want to use this inside your company you should set up a maven repository like Nexus or Archiva. Then you deploy your own bundle using mvn clean deploy into your company repo. Of course this will require that you set up your pom correctly but you will need that anyway for any larger project.

The last step needed is then to set up your Fuse ESB / Karaf to also use your company repo. This is done by adding the repo uri to the file etc/org.ops4j.pax.url.mvn.cfg.

Of course this is a little more work than the http url that Neil proposed. THe advantage is that this will integrate very well with your maven build process and it will make your bundle mvn uris independent of the location of your maven repo. It will also allow you to mix your own bundles and open source bundles when you start to combine them using features.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
  • +1, i recommend this approach if maven is being used. In my opinion "install file://" should be limited to development environment. – techuser soma May 06 '13 at 03:15
  • @Christian If install bundle from a remote repository, does Fuse ESB download it first and then install it locally? – Li' May 30 '13 at 06:36
  • No idea if Fuse ESB is different there. I can only explain how Apache Karaf does it. In Apache Karaf 2.x the bundles you load from the repo will not be cached locally. The upcoming Apache Karaf 3 will use your local maven repository as a cache. – Christian Schneider May 30 '13 at 07:24
  • @ChristianSchneider Do you mean the bundle which is installed from remote repository will run on a different host from the host on which Karaf is running? – Li' May 30 '13 at 08:35
  • The bundles run inside the local karaf container of course. I was just refering to the caching. So in 2.x the bundles have to be loaded from the remote repository each timee you do a clean start while in Karaf 3 the bundles are cached. – Christian Schneider May 30 '13 at 15:42
  • @ChristianSchneider Is it possible that the can run outside the local karaf container. For example, bundle A is running on Host1 but is installed and registered with karaf on Host2? I post a question about this at: http://stackoverflow.com/questions/16721457/osgi-how-to-install-two-identical-bundle/16734928#comment24260673_16734928 – Li' May 30 '13 at 16:55
  • Bundles can only be registered locally. Can you explain what you try to achieve? Perhaps there is another way to solve this. – Christian Schneider May 31 '13 at 13:35
  • @ChristianSchneider I have created a bundle floodlight which is a switch controller. I want it to run on a host but register it to Fuse ESB on another host. I want to separate the location of bundle and Fuse ESB. I am not sure if this remote registration can work. – Li' Jun 05 '13 at 02:56
  • You cannot really register bundles on a remote machine. I think what you could need is to register an osgi service on the remote machine. See cxf dosgi for the reference implementation. – Christian Schneider Jun 11 '13 at 12:57