felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com.INVALID>
Subject Re: Logging uncaught exceptions?
Date Thu, 04 Aug 2016 19:37:02 GMT
BundleActivator behavior and DS component behavior are completely unrelated.

I strongly suspect that you haven’t installed anything to record the logging or display
it to you?  IIRC pax-logging is a popular way to hook osgi logging up to slf4j and make it
easy to configure where it goes.

thanks
david jencks

> On Aug 4, 2016, at 12:29 PM, list+org.apache.felix@io7m.com wrote:
> 
> Hello.
> 
> I have a simple declarative service such as:
> 
> --8<--
> @Component(immediate = true)
> public final class Speaker implements SpeakerType
> {
>  public Speaker()
>  {
>    System.out.println("Speaker (declarative): constructor");
>  }
> 
>  @Activate
>  private void onActivate()
>  {
>    System.out.println("Speaker (declarative): onActivate");
>  }
> 
>  @Override
>  public void speak(final String text)
>  {
>    System.out.println("Speaker (declarative): speak: " + text);
>  }
> }
> -->8--
> 
> If I throw an exception in either the constructor or the onActivate()
> method, I get no indication that this has happened. A quick search
> through the core spec for the word "exceptions" leads me to 9.3.6,
> which I think may be relevant even though I'm going through the
> declarative services service:
> 
>  If the BundleActivator.start or stop method throws an Exception, then
>  the handling of this Exception is different depending who invoked
>  the start or stop method. 
> 
>  If the bundle is started/stopped due to a change in the active start
>  level or the bundle's start level, then the Exception must be wrapped
>  in a BundleException and broadcast as a FrameworkEvent.ERROR event.
>  Otherwise, a new BundleException must be created containing the
>  exception and this BundleException is then thrown to the caller.
> 
> So I assume that I need to register some sort of listener to receive
> errors. However, even assuming that I do this: What if the exception is
> of a type that the listener does not import?
> 
> Is there a bundle in the distribution that handles this? I have the Log
> service installed, but that doesn't appear to do anything (unless it
> requires extra configuration - I've not given it any). I just
> want errors logged to the console during development so that I don't
> sit here trying to debug silent failures.
> 
> M


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Mime
View raw message