The other day I was running an OSGi project with JDK8 and noticed, that the javax.swing package could not be found. This worked in JDK7. Switching to JDK8 in osgisnippets was leading to the following error, when Swing is about to be loaded:
The reason is simple: A Felix version was used, which does not know about JDK8. Upgrading to a newer version like org.apache.felix.main-4.2.1.jar solves the issue.
The OSGi framework makes java.* packages available automatically. The JDK contains several packages outside the java.* namespace such as javax.swing or org.xml.sax, which are made available too, but specific to the Java version. The felix main jar contains a file default.properties which also defines the exported packages for each Java version. So felix detected jre-1.8, but in the default.properties file of v4.0.2 there is no entry for that. Hence all the extra JRE packages (other than java.*) were not exported.
Resources
- Apache Felix: http://felix.apache.org/
-
Source code of OSGi snippets is at the project site:
https://sourceforge.net/projects/osgisnippets/
Keine Kommentare:
Kommentar veröffentlichen