Deploying a pre-existing bundle on OSGi OBR

September 15th, 2014

Using the maven-bundle-plugin, you can deploy a preexisting jar bundle from your local maven repository to your remote OBR. For this you use the deploy-file target of the maven-bundle-plugin directly, with a command line like:

mvn org.apache.felix:maven-bundle-plugin:2.4.0:deploy-file

where my-repository-id is the id you also use in your settings.xml for storing the access data (username, private key, passphrase etc).

In my case, this simple command failed with the error:

[ERROR] Failed to execute goal org.apache.felix:maven-bundle-plugin:2.4.0:deploy-file (default-cli) on project standalone-pom: Unsupported protocol: 'scp': Cannot find wagon which supports the requested protocol: scp: java.util.NoSuchElementException
[ERROR] role: org.apache.maven.wagon.Wagon
[ERROR] roleHint: scp

and later

Error injecting: org.apache.maven.wagon.providers.ssh.jsch.ScpWagon

and even later
Error injecting: org.apache.maven.wagon.providers.ssh.jsch.interactive.PrompterUIKeyboardInteractive

To resolve this, I had to add the following jars to the %M2_HOME/lib directory (so they are added to the classpath).

  • wagon-ssh-2.5.jar
  • wagon-ssh-common-2.5.jar
  • jsch-0.1.51.jar
  • plexus-interactivity-api-1.0-alpha-6.jar

M2_HOME is where the maven executable are located, in my case C:\springsource\apache-maven-3.0.3\lib and which can be found (on windows) by executing:
where mvn

java, maven, osgi

Felix Gogo shell command examples & cheat sheet

June 15th, 2014

A short overview of frequently used Felix Gogo OSGi commands with examples.

    • List all installed bundles on the system (nb. lb is short for list-bundles)
      g! lb
      ID|State |Level|Name
      0|Active | 0|System Bundle (4.2.1)
      1|Active | 1|Apache Felix Bundle Repository (1.6.6)
    • Get the current framework startlevel and then sets it. When setting a new level, all levels in between the current and the new level are activated in between.
      g! frameworklevel
      Level is 1
      g! frameworklevel 2
      g! frameworklevel
      Level is 2
    • For bundles which will be newly installed, set which bundle start level they will have assigned (here level 3) after install
      g! bundlelevel -i 3
    • For bundles already installed, set the bundle start level, here to level 5 for bundles 94 and 172
      g! bundlelevel -s 5 94 172
    • Set bundle 23 to be started, when the frameworklevel gets equal or above the bundle’s start level (resp stop)
      g! start 23
      g! stop 23
    • Install a bundle from a local file or a remote location. (note using a repository instead of direct links is described below)
      g! install file:///path/to/bundle.jar
      Bundle ID: 173
      g! install
      Bundle ID: 174
    • Update a bundle from it’s default location (here bundle 174)
      g! update 174
    • Uninstall a bundle
      g! uninstall 174
    • Get detailed infos on a bundles headers (basically the manifest content)
      g! headers 3
      Apache Felix EventAdmin (3)
      Bnd-LastModified = 1349073346464
      Bundle-SymbolicName = org.apache.felix.eventadmin
      Bundle-Version = 1.3.2
      Export-Package = org.osgi.service.event;uses:="org.osgi.framework";version="1.3"


  • Get list of services offered by a bundle (here bundle 2)
    g! inspect capability service 2
    org.apache.felix.configadmin [2] provides:
    service; with properties:
    service.description = Platform Filesystem Persistence Manager = 5 =
    service.ranking = -2147483648
    service.vendor = Apache Software Foundation
    Used by:
    org.apache.felix.configadmin [2]
  • Refresh bundles, so that they let go of old packages and surely use the new ones you just updated. If neceessary this will restart the bundles
    g! refresh
  • Print the System properties
    g! system:getproperties
    java.vm.version 24.51-b03
    sun.jnu.encoding ANSI_X3.4-1968


Interaction with an OBR, a remote OSGi bundle repository

  • List all and add remote repositories
    g! repos list
    No repository URLs are set.
    g! repos add
    g! repos list
  • Refresh the list of provided bundle of a repository
    repos refresh
  • List content of remote repositories
    g! list
    My First Bundle (0.0.1.SNAPSHOT)
    My Second Bundle (0.0.3.SNAPSHOT, ...)
  • Install from remote repository
    g! deploy "My First Bundle"
    Target resource(s):
    My First Bundle (0.0.1.SNAPSHOT)

Built-in commands

  • Use grep to filter output.
    g! lb | grep Felix
      1|Active     |    1|Apache Felix Configuration Admin Service (1.8.0)
     37|Active     |    1|Apache Felix Dependency Manager (3.2.0)

Using registered services

  • Get a service and call methods on it
    _sref = $.context getServiceReference "com.example.MyServiceInterface"
    _srv = $.context getService $_sref
    $_srv getFooBar
    $.context ungetService $_sref

    or with a filter

    _srefs = $.context getServiceReferences "com.example.MyServiceInterface" "(filterKey=filterValue)";
    _srv = $.context getService ($_srefs 0)
    $_srv getFooBar
    _srv = $.context ungetService ($_srefs 0)

osgi, Uncategorized

Maven Eclipse (m2e) SCM connector for subclipse 1.10 (svn 1.8)

December 19th, 2013

Running Maven m2e on Eclipse Kepler (4.3) with subversion is not working out of the box, which is astonishing when taking into account the ubiquity of these three technologies Eclipse/Maven/Subversion.

In short my successful attempt:

  • Installed Eclipse Kepler 4.3 (which comes with m2e)
  • Installed from Marketplace Subclipse 1.10 (update site is

Now to check out a maven project from an SVN repository, you need an SCM connector for m2e. Unfortunately, at the time of writing, no connector is available for subclipse, neither from m2e nor from tigris. The following unofficial project has a working connector But there’s no corresponding update site – you need to get the code, build it, and use the output update site.

To simplify this step for future installations, I compiled that connector and make it available here

How to install the SCM connector:

  • download zip
  • unzip the file to an empty folder somewhere, remember that folder
  • In Eclipse,
    • go to Help/Install New Software…
    • Click “Add…” to add a new site
    • In the window, click on “Local…” and choose the folder where you unzipped the site before. The result in the Location field should look like file:/C:/theUnzipFolder/
    • Click OK, choose all available packages to install, and continue the installation as usual

Hope this helps somebody.


Associate files without extension to a given programm or editor

January 18th, 2013

(Info found on

In Windows 7, to associate a default program to files without extension (eg. README or INSTALL) you need to

  • open cmd.exe as administrator
  • execute the following commands:
    >assoc .="No Extension"
    >ftype "No Extension"="C:\Program Files (x86)\TextPad 4\TextPad.exe" "%1"
    >assoc "No Extension"\DefaultIcon=%SystemRoot%\System32\imageres.dll,-102
  • Obviously, adapt the path to the editor you want to use.


    Install plugins in Eclipse in Windows 7

    July 29th, 2011

    Starting with Windows 7 and Eclipse Indigo you need to start Eclipse as administrator to be able to install plugins.
    This is true as well for plugins which do not have an install site. Those plugins must be placed in the dropins folder of your eclipse install.


    ant scp needs jsch.jar in Eclipse

    July 29th, 2011

    If in Eclipse, using ant scp you get the error:

    Cause: Could not load a dependent class com/jcraft/jsch/Logger
    It is not enough to have Ant's optional JARs
    you need the JAR files that the optional tasks depend upon.
    Ant's optional task dependencies are listed in the manual.
    Action: Determine what extra JAR files are needed, and place them in one of:
    -C:\Program Files (x86)\Eclipse\plugins\org.apache.ant_1.8.2.v20110505-1300\lib
    -a directory added on the command line with the -lib argument

    Do not panic, this is a common problem.
    The commonest cause is a missing JAR.

    This is not a bug; it is a configuration problem

    You need to do 3 things:

    1. get jsch.jar from
    2. place it in the ant folder as indicated in the error
    3. add the jar to the ant classpath in Eclipse
      Window/Preferences/Ant/Runtime/Ant Home Entries – Add external JARs, choose your jsch.jar


    Make Google Desktop search for local files per default

    January 4th, 2011

    Google Desktop Search per default searches the web. In order to make it search the local files per default, change the following registry key:

    [HKEY_CURRENT_USER\Software\Google\Google Desktop\Deskbar]
    “search_type”=”Search Desktop”


    USB modem drivers for Kies / Samsung mobile phone

    December 17th, 2010

    I just got my new Samsung GT-B5722 phone. There’s PC synchronization software that comes with it called Kies. I connect the PC to the phone using the USB cable – but my Windows XP complains that it cannot find the relevant Samsung USB modem driver and the device does not show up in Kies.

    We need to find & install the USB drivers.

    These can be found on the delivered CD, in a file at
    F:\Kies\CabFile\USB Driver\
    (where F: is the CD drive).
    Decompress & extract this file using for example WinRAR, you will get the program file SAMSUNG_USB_Driver_for_Mobile_Phones.exe. Execute it, and all necessary drivers will be installed.

    Uncategorized ,

    Convert byte to binary representation

    March 16th, 2010

    Use the following to show a byte value in binary representation.

     * Returns a 0 padded binary representation of the 
     * passed byte. For example, returns "00000001" if passed
     * the byte 1. Returns "11111111" if passed byte -1.
     * @param b the byte 
     * @return the byte in binary representation
    private static String toBinary(byte b){
    	StringBuffer sb = new StringBuffer(8);
    	for(int bit = 7; bit >= 0; bit--) {
    		if ((b & (1 << bit)) > 0)
    	return sb.toString();


    Eclipse running in a JDK to use Maven tools

    January 7th, 2010

    The Maven Intergation requires that Eclipse be running in a JDK and that installed JREs are also using JDK installs. In order to achieve this, edit your eclipse.ini file, located for example at C:\Program Files\eclipse\eclipse.ini. You need to specify the virtual machine to use. Add the following lines to the file before any -vmargs:

    C:\Program Files\Java\jdk1.6.0_16\bin\javaw.exe


    • -vm and the JDK location are on separate lines
    • No quotes around the path
    • The two lines must come before any -vmargs

    Uncategorized ,