Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run/Debug OSGi application in Eclipse

Tags:

eclipse

osgi

Our app has migrated to OSGi, but I have trouble starting/debugging it in Eclipse. What is the process: is OSGi application developer expected to set up Equinox environment, install hundreds of bundles (jar=bundle?), and start from console? In other words, is launching "hot-plug-gifted" application different from "modular-challenged" one?

Secondary, more concrete question. There is a bootstrap bundle which is supposed to take care of everything, but after loading bunch of classes it slows down and almost hangs at:

...
...
...
Flat profile of 0.22 secs (16 total ticks): main

  Interpreted + native   Method                        
 16.7%     1  +     0    java.awt.Toolkit.addAWTEventLi[Loaded java.awt.SentEvent from C:\Program Files\Java\jdk1.7.0_04\jre\lib\rt.jar]
stener
 16.7%     1  +     0    jav[Loaded java.awt.DefaultKeyboardFocusManager$DefaultKeyboardFocusManagerSentEvent from C:\Program Files\Java\jdk1.7.0_04\jre\lib\rt.jar]
a.util.regex.Pattern.compile
 16.7%     1  +     0    sun.util.logging.PlatformLogger.<init>
 50.0%     3  +     0    Total interpreted

  Thread-local ticks:
 62.5%    10             Blocked (of total)
 50.0%     3             Class loader

...
...
...
[Loaded sun.reflect.Label$PatchInfo from C:\Program Files\Java\jdk1.7.0_04\jre\lib\rt.jar]
[Loaded sun.reflect.MethodAccessorGenerator$1 from C:\Program Files\Java\jdk1.7.0_04\jre\lib\rt.jar]
[Loaded sun.reflect.ClassDefiner from C:\Program Files\Java\jdk1.7.0_04\jre\lib\rt.jar]
[Loaded sun.reflect.ClassDefiner$1 from C:\Program Files\Java\jdk1.7.0_04\jre\lib\rt.jar]
[Loaded sun.reflect.GeneratedMethodAccessor1 from __JVM_DefineClass__]
[Dynamic-linking native method sun.java2d.DefaultDisposerRecord.invokeNativeDispose ... JNI]
[Dynamic-linking native method java.lang.ref.Finalizer.invokeFinalizeMethod ... JNI]

Edit: progressed a little since question posting

[Loaded sun.reflect.GeneratedMethodAccessor1 from __JVM_DefineClass__]
[Dynamic-linking native method sun.java2d.DefaultDisposerRecord.invokeNativeDispose ... JNI]
[Dynamic-linking native method java.lang.ref.Finalizer.invokeFinalizeMethod ... JNI]
--- new stuff --- 
[Loaded sun.awt.windows.WComponentPeer$2 from C:\Program Files\Java\jdk1.7.0_04\jre\lib\rt.jar]
[Dynamic-linking native method sun.awt.windows.WInputMethod.disableNativeIME ... JNI]

Thus it is not a deadlock, what might make it so excrutiatingly slow?

like image 953
Tegiri Nenashi Avatar asked May 04 '12 21:05

Tegiri Nenashi


People also ask

What is OSGi in eclipse?

OSGi, The Dynamic Module System for Java Its proven services model enables application and infrastructure modules to communicate locally and distributed across the network, providing a coherent end-to-end architecture. OSGi specifications have been extensively field-tested and are ready to use.

How do I open OSGi console?

An OSGi console is now available to interact with the running framework. Use the Open Console drop down action in the Console View to open a Host OSGi Console. You can then enter OSGi commands into the console to interact directly with the framework running the IDE.


1 Answers

Launching and debugging in Eclipse should be fairly staightforward. The trick (in my view) is to realise that all the Eclipse support you need is labelled 'plug-in' instead of 'OSGi'. Set up a target platform with all the external bundles you need - you can just dump them into a directory and then point the target platform configurator at that folder. The target platform configuration is under Preferences->Plug-in Development->Target Platform. You can share the target platform as a .target file. Having a good target platform helps with both running and compiling.

To run your bundles, right click and choose Run as ->OSGi Framework (or debug as). You can tweak which bundles are included in the runtime configuration, and what arguments are used. You may for example want to add -console. You can also create an application for export, which will give you a config.ini file. Once you have a config.ini, your bundles will be pre-installed on Equinox startup.

like image 142
Holly Cummins Avatar answered Nov 15 '22 06:11

Holly Cummins