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
-DrepositoryId=my-repository-id
-Durl=scp://url/to/my/repository
-DpomFile=C:\Users\myuser\.m2\repository\com\...\the-bundle-to-deploy-1.0.0.pom
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
Phil java, maven, osgi
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
START LEVEL 1
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 http://www.example.com/path/to/bundle.jar
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; org.apache.felix.cm.PersistenceManager with properties:
service.description = Platform Filesystem Persistence Manager
service.id = 5
service.pid = org.apache.felix.cm.file.FilePersistenceManager
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 http://updates.example.com/repository/repository.xml
g! repos list
http://updates.example.com/repository/repository.xml
- Refresh the list of provided bundle of a repository
repos refresh http://updates.example.com/repository/repository.xml
- 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)
Deploying...
done.
Built-in commands
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)
Phil osgi, Uncategorized
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 http://subclipse.tigris.org/update_1.10.x)
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 https://github.com/tesla/m2eclipse-subclipse. 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 org.sonatype.m2e.subclipse.feature-0.13.0-SNAPSHOT-site.zip
How to install the SCM connector:
- download zip org.sonatype.m2e.subclipse.feature-0.13.0-SNAPSHOT-site.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.
Phil Uncategorized
(Info found on superuser.com)
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.
Phil Uncategorized
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.
Phil Uncategorized
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
-C:\Users\pbu.DESKTOP-KSA\.ant\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:
- get
jsch.jar
from http://www.jcraft.com/jsch/
- place it in the ant folder as indicated in the error
- add the jar to the ant classpath in Eclipse
Window/Preferences/Ant/Runtime/Ant Home Entries – Add external JARs, choose your jsch.jar
Phil Uncategorized
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”
Phil Uncategorized Google Desktop Search
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\SAMSUNG_USB_Driver_for_Mobile_Phones.exe.cab
(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.
Phil Uncategorized mobile phone, Samsung
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)
sb.append('1');
else
sb.append('0');
}
return sb.toString();
}
Phil Uncategorized java
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
:
-vm
C:\Program Files\Java\jdk1.6.0_16\bin\javaw.exe
Note:
-vm
and the JDK location are on separate lines
- No quotes around the path
- The two lines must come before any
-vmargs
Phil Uncategorized Eclipse, Maven