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
pgpJbtjsWFhgQ.pgp
Description: OpenPGP digital signature

