Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Being notified when a bundle throws an exception - OSGi - Helios
Being notified when a bundle throws an exception - OSGi - Helios [message #779025] Sat, 14 January 2012 12:43 Go to next message
Zardosht Hodaie is currently offline Zardosht HodaieFriend
Messages: 4
Registered: December 2011
Junior Member
Hi,

If a bundle throws an exception in osgi, the stack-trace is printed on
the osgi console. In the case, the bundle is in GUI thread of eclipse,
an error log entry apears in error log with "unhandled event loop
exception". I can add a listener to error log and get the IStatus object
related to that.
However if the bundle is not in GUI thread, there is not notification. I
want to be notified if a bundle throws an exception. I thought using
osgi logging service could help about it. However I could not get it to
work under Helios.

The question is how can I be notified if a bundle throws an exception in
osgi Helios.

Or if osgi logging does the work, how can I get osgi logging to work in
Helios? As much as I googled, there is apparently no implementation of
osgi loggin service currently integrated in helios. I downloaded the
equinox skd 3.6 from eclipse site that contains the bundle
org.eclipse.equinox.log, however I could add it as dependency to my
plugins, or install it in the osgi runtime.

Any help is really appreciated.
Re: Being notified when a bundle throws an exception - OSGi - Helios [message #779278 is a reply to message #779025] Sun, 15 January 2012 07:42 Go to previous messageGo to next message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Am 14.01.2012 13:43, schrieb Zardosht Hodaie:
> The question is how can I be notified if a bundle throws an exception in
> osgi Helios.

There is no standard mechanism for that in OSGi that I'm aware if.
Usually the code which throws an exception is executed by some other
code. It really depends on the implementation of that other code how an
exception is handled.

For example, in SWT/GUI the event loop catches all exceptions and sends
them to a handler which logs them. Errors are treated special so that an
OOME can be detected and a dialog can be shown.

The Eclipse Jobs API is another example which also catches exceptions
and logs them.

As long as your code is concerned I suggest handling exceptions right in
your code and the use of some logging framework (eg. SLF4J or OSGi log
service or Equinox/Eclipse runtime log).

-Gunnar

--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
Re: Being notified when a bundle throws an exception - OSGi - Helios [message #780495 is a reply to message #779278] Wed, 18 January 2012 10:33 Go to previous message
Zardosht Hodaie is currently offline Zardosht HodaieFriend
Messages: 4
Registered: December 2011
Junior Member
Hi Gunnar,

thank you for your reply. The thing is, that I have no access to the
code that throws the exception. I have an eclipse application given to
me without source code. My job is to know if the code of this
application throws an exception. To do this, I start my own bundles
(that listen to GUI error log) in the OSGi runtime of the target
application. This way if code that starts from application GUI throws an
exception I become aware of it.
Nevertheless, this would not work if some code is not invoked from GUI,
for example some background job that starts as soon as application
starts. I thought that there might be some way in OSGi to be aware of
these kind of bundles (those not having any GUI) throwing an exception.
However it looks like there is no way for it.

Thanks,
Zardosht


Am 15.01.2012 08:42, schrieb Gunnar Wagenknecht:
> Am 14.01.2012 13:43, schrieb Zardosht Hodaie:
>> The question is how can I be notified if a bundle throws an exception in
>> osgi Helios.
>
> There is no standard mechanism for that in OSGi that I'm aware if.
> Usually the code which throws an exception is executed by some other
> code. It really depends on the implementation of that other code how an
> exception is handled.
>
> For example, in SWT/GUI the event loop catches all exceptions and sends
> them to a handler which logs them. Errors are treated special so that an
> OOME can be detected and a dialog can be shown.
>
> The Eclipse Jobs API is another example which also catches exceptions
> and logs them.
>
> As long as your code is concerned I suggest handling exceptions right in
> your code and the use of some logging framework (eg. SLF4J or OSGi log
> service or Equinox/Eclipse runtime log).
>
> -Gunnar
>
Previous Topic:Equinox system bundle not exporting packages in embedded scenario.
Next Topic:How to plug a different i18n mechanism
Goto Forum:
  


Current Time: Tue Mar 19 02:02:49 GMT 2024

Powered by FUDForum. Page generated in 0.03150 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top