I am developing an OSGi based TornadoFX desktop app by following this toturial. Before getting started with coding, I wanted to prepare the OSGi environment. For that, I installed Apache Felix 5.6.10 and the required bundles.
Felix and all required bundles work properly as shown in here (the output of the lb command):
ID|State |Level|Name
0|Active | 0|System Bundle (5.6.10)|5.6.10
1|Active | 1|Apache Commons Logging (1.2.0)|1.2.0
2|Active | 1|Apache Apache HttpClient OSGi bundle (4.5.5)|4.5.5
3|Active | 1|Apache Apache HttpCore OSGi bundle (4.4.9)|4.4.9
4|Active | 1|jansi (1.16.0)|1.16.0
5|Resolved | 1|JavaFX 8 OSGi extension bundle (8.0.1)|8.0.1
7|Active | 1|JLine Bundle (3.5.1)|3.5.1
8|Active | 1|kotlin-osgi-bundle (1.2.31)|1.2.31
9|Active | 1|Apache Felix Bundle Repository (2.0.10)|2.0.10
10|Active | 1|Apache Felix Configuration Admin Service (1.8.16)|1.8.16
11|Active | 1|Apache Felix Gogo Command (1.0.2)|1.0.2
12|Active | 1|Apache Felix Gogo JLine Shell (1.0.10)|1.0.10
13|Active | 1|Apache Felix Gogo Runtime (1.0.10)|1.0.10
18|Active | 1|Apache Felix Gogo Shell (1.0.0)|1.0.0
22|Active | 1|JSR 353 (JSON Processing) Default Provider (1.0.0)|1.0.0
However, I can not start the TornadoFX bundle! I installed tornadofx-1.7.15.jar using install tornadofx-1.7.15.jar, which was OK, but when I tried to start it, the following exception is thrown:
I am using java -jar bin/felix.jar on the command line to launch Felix. All the interested bundles are in the bundle folder beneath Felix's root folder. Also, I am trying to make it work under IntelliJ, but this can be an independent thread.
org.osgi.framework.BundleException: Unable to resolve no.tornado.tornadofx [26](R 26.0):
missing requirement [no.tornado.tornadofx [26](R 26.0)] osgi.wiring.package; (osgi.wiring.package=com.sun.glass.ui) Unresolved requirements:
[[no.tornado.tornadofx [26](R 26.0)] osgi.wiring.package; (osgi.wiring.package=com.sun.glass.ui)]
Now the question is that how can I make it work? Is there any other bundle that I should install beforehand? what is com.sun.glass.ui for and how to add it to the bundles or classpath?
This error message means that the bundle no.tornado.tornadofx imports package com.sun.glass.ui, but you do not have a bundle installed that exports that package.
That package is delivered as part of some JDKs, but OSGi does not export by default because it is not part of the Java SE standard. Assuming your JDK includes it, you can export from the system bundle by setting the launch property:
org.osgi.framework.system.packages.extra=com.sun.glass.ui
You haven't said exactly how you are launching Felix so I can't give specific details on how to set this property. If you have difficulty then edit the question to supply more information this.
Related
We need FindBugs JSR305 as a dependency and we deploy it as a wrapped OSGi bundle to Fuse 6.3.0. At first it looks like everything is fine and the components are working well. But after a restart, many bundles that depend on javax.annoation API are not starting anymore. We found out, that the javax.annoation API Bundle that comes with the Fuse installation does not export the package javax.annoation after the restart. Although the bundle of the javax.annotation API starts without errors and exports other packages.
The error occurs with RedHat Fuse 6.3.0.475 and the corresponding Karaf 2.4.0.redhat-630475.
We already tried the ServiceMix JSR305 Bundle from Maven Repository, but it exports the javax.annotation in version 1.1.0 and we need version 3.0.2. Maybe this is a mistake too, because I would expect an export of javax.annotation 3.0.2 from the bundle version 3.0.2_1.
Manifest-Version: 1.0
Bnd-LastModified: 1493877706145
Build-Jdk: 1.8.0_111
Built-By: jbonofre
Bundle-Description: This OSGi bundle wraps jsr305 1.1.0 jar file.
Bundle-DocURL: http://www.apache.org/
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-ManifestVersion: 2
Bundle-Name: Apache ServiceMix :: Bundles :: jsr305
Bundle-SymbolicName: org.apache.servicemix.bundles.jsr305
Bundle-Vendor: The Apache Software Foundation
Bundle-Version: 3.0.2.1
Created-By: Apache Maven Bundle Plugin
Export-Package: javax.annotation;version="1.1.0";uses:="javax.annotation.meta",javax.annotation.concurrent;version="1.1.0",javax.annotation.meta;version="1.1.0";uses:="javax.annotation"
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.5))"
Tool: Bnd-3.2.0.201605172007
Reproduction
Setup a new Fuse 6.3.0 installation. With "pacakges:exports | grep javax.annoation;" you can find out that javax.annoation is exported in version 1.0.0 from System Bundle and in version 1.2.0 from javax.annoation API.
JBossFuse:karaf#root> packages:exports | grep javax.annotation\;
0 javax.annotation; version=1.0.0
60 javax.annotation; version=1.2.0
Now install FindBugs JSR305 as a wrapped OSGi bundle to the instance. There are three exports of the javax.annotation package now including version 3.0.2 of the FindBugs JSR305 bundle and everything is working.
JBossFuse:karaf#root> packages:exports | grep javax.annotation\;
0 javax.annotation; version=1.0.0
60 javax.annotation; version=1.2.0
294 javax.annotation; version=3.0.2
Now restart the instance via admin script or "dev:restart" and after the instance is up again you will see some broken bundles, because javax.annoation API stopped to export version 1.2.0 of the javax.annotation package.
JBossFuse:karaf#root> packages:exports | grep javax.annotation\;
0 javax.annotation; version=1.0.0
294 javax.annotation; version=3.0.2
If you try the same with a fresh Fuse 7.0.0 installation, which runs with Karaf 4.2.0 and where javax.annotation API is still included, the error will not occur. It also works with Fuse 7.7.0, but there javax.annotation API is not included anymore and the java.annotation packages are exported just from Sytem Bundle.
I had the same problem (and yes - in JBoss Fuse). After upgrading to Zookeeper 3.4.14 we had this in mvn dependency:tree:
[INFO] | \- org.apache.zookeeper:zookeeper:jar:3.4.14:compile
[INFO] | +- org.slf4j:slf4j-log4j12:jar:1.7.10:compile
[INFO] | +- com.github.spotbugs:spotbugs-annotations:jar:3.1.9:compile
[INFO] | | \- com.google.code.findbugs:jsr305:jar:3.0.2:compile
Findbugs library is simply broken:
JBossFuse:karaf#root> install mvn:com.google.code.findbugs/jsr305/3.0.2
Bundle ID: 295
JBossFuse:karaf#root> headers 295
FindBugs-jsr305 (295)
---------------------
Archiver-Version = Plexus Archiver
Created-By = Apache Maven Bundle Plugin
Manifest-Version = 1.0
Bnd-LastModified = 1490936130302
Build-Jdk = 1.8.0_101
Built-By = lan
Tool = Bnd-2.1.0.20130426-122213
Bundle-License = http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-ManifestVersion = 2
Bundle-SymbolicName = org.jsr-305
Bundle-Version = 3.0.2
Bundle-Name = FindBugs-jsr305
Bundle-Description = JSR305 Annotations for Findbugs
Export-Package =
javax.annotation;uses:=javax.annotation.meta;version=3.0.2,
javax.annotation.concurrent;version=3.0.2,
javax.annotation.meta;uses:=javax.annotation;version=3.0.2
because it exports javax.annotation package with non existing version. If you check JSR 250, Common Annotations for the JavaTM Platform, its version should be 1.3 and it matches the versions from Maven Central.
In our case, we've changed activemq-osgi to import javax.annotation;version="[1,4)" instead of just javax.annotation, so maven-bundle-plugin didn't generate bad javax.annotation;version="[3,4)".
But IMO, findbugs should NOT use javax.annotation package at all...
I am learning osgi, and I installed apache felix (6.0.3), when I executed the following command.
java -jar felix.jar
Felix doesn't display the shell gogo,and I don't know why ?
OSGi is a modular system. You've just started the framework. The framework does not have any behavior, as it should. You need to install bundles to get any behavior. This includes the shell.
I've written an OSGi Starter based on gogo & Bndtools. You can find it here:
https://bndtools.org/workspace/osgi-starter.html
The gogo shell is implemented in separate bundles. You only start the framework without any bundles.
I propose a tooling like bnd to set up felix with the required bundles. See my osgi ds hello world example. It starts the shell and also shows how you can build and deploy your own code.
I have created an OSGi bundle, that is using apache commons dbcp2 to create a database connection pool. I am using apache felix gogo as runtime to start my bundles. I have loaded multiple other external libraries without any problems into the apache felix:
Image here (cant post no rep):
https://i.gyazo.com/c779ccaba20e3fa327d61a621748d8dc.png
However every time I try to start dbcp2 bundle which is requiered in my bundle I get the following error:
Image here (cant post no rep):
https://i.gyazo.com/ac7b673e63b9e6ad764af2e6adddb19a.png
I have found that there is some Apache mixservice bundle available, but it contains dbcp 1.4 and I need dbcp 2.5.0 or higher.
What needs to be done so apache felix is able to load the dbcp2 as a library requiered by other projects ?
What you see in the error is that the dbcp bundle requires the javax.transaction package in version >= 1.1.0. This is not an error in the bundle. It just means that you need to provide this package in the OSGi container.
Normally you would install a bundle that provides the package. In this case the package comes from the jre and the system bundle should export it.
Depending on how you start felix the way to export a system package is different.
For example if you use bndtools you do this in a bndrun file. See the Enroute microsevice example.
For plain felix see the parameter "org.osgi.framework.system.packages.extra".
In this example the javax.transaction package is exported (among some others).
On installing BndTools for Code for Apache Felix using OSGi getting this error :
The selected wizard could not be started. Plug-in "bndtools.core" was unable to instantiate class "bndtools.wizards.project.NewBndProjectWizardFactory". org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne
I'm installing this tool in Eclipse Mars.
Folks,
I'm trying to get the apache Felix webconsole running on an eclipse Virgo 3.0.3 installation -- I need the extra details it provides that the standard virgo admin doesn't.
I uploaded the full org.apache.felix.webconosle-3.1.8.jar to the pickup dir.
This virgo Jetty is running at port 8098, but when I do:
host:8098/system/console
I am getting the 404 not found.
Any ideas here how to get the webconsole integrated into the Eclipse Virgo Jetty install?
Thanks!
Although I didn't use Virgo in a long time, I guess it is because the installation is missing a standard OSGi HTTP service, which is required for the Felix web console bundle to work. You need to install a bundle that exports such a service based on the Jetty bundle you are using.