How to configure a system-wide package in osgi?

I need to provide a library for some packages. This library uses RMI, therefore (to my knowledge, at least) to use the system class loader to work (I tried to use "osgi-fy" in the library, which results in classcastexceptions at runtime). So what I did to remove the dependencies from packages that use this library was to compile them with the library included in the jars.extra.classpath property (in the build.properties of the eclipse project).

Then i added

org.osgi.framework.bootdelegation=com.blipsystems.* 

in the felix configuration file and launched the felix container with the following command line:

 java -classpath lib/blipnetapi.jar -jar bin/felix.jar 

.. which, in turn, threw a NoClassDefFoundException for the blipnetapi.jar library class:

  ERROR: Error starting file: /home/frza/felix/load/BlipnetApiOsgiService_1.0.0.1.jar (org.osgi.framework.BundleException: Activator start error in bundle BlipnetApiOsgiService [30].)
 java.lang.NoClassDefFoundError: com / blipsystems / blipnet / api / util / BlipNetSecurityManager
     at java.lang.Class.getDeclaredConstructors0 (Native Method)
     at java.lang.Class.privateGetDeclaredConstructors (Class.java:2389)
     at java.lang.Class.getConstructor0 (Class.java:2699)
     at java.lang.Class.newInstance0 (Class.java:326)
     at java.lang.Class.newInstance (Class.java:308)
     at org.apache.felix.framework.Felix.createBundleActivator (Felix.java:3525)
     at org.apache.felix.framework.Felix.activateBundle (Felix.java:1694)
     at org.apache.felix.framework.Felix.startBundle (Felix.java:1621)
     at org.apache.felix.framework.Felix.setActiveStartLevel (Felix.java:1076)
     at org.apache.felix.framework.StartLevelImpl.run (StartLevelImpl.java:264)
     at java.lang.Thread.run (Thread.java:619)
 Caused by: java.lang.ClassNotFoundException: com.blipsystems.blipnet.api.util.BlipNetSecurityManager
     at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation (ModuleImpl.java:726)
     at org.apache.felix.framework.ModuleImpl.access $ 100 (ModuleImpl.java:60)
     at org.apache.felix.framework.ModuleImpl $ ModuleClassLoader.loadClass (ModuleImpl.java:1631)
     at java.lang.ClassLoader.loadClass (ClassLoader.java:251)
     at java.lang.ClassLoader.loadClassInternal (ClassLoader.javahaps19)
     ... 11 more

So my question is: am I missing something? Did I do something wrong?

0
source share
1 answer

The problem is on the command line. If you specify the -jar parameter, java will ignore the -classpath parameter. If you need to specify the class path with -jar, it must be in the manifest of the jar that you run. Here, I would simply put both banks in the class path and manually set the main class (look inside the flix for its exact name).

0
source

All Articles