You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2008/01/14 17:46:43 UTC

jackrabbit.server bundle fails if started before ConfigAdmin

Hi,

Currently org.apache.sling.jcr.jackrabbit.server.Activator does this:

    public void start(BundleContext context) throws Exception {
        ....
        ServiceReference sr =
context.getServiceReference(ConfigurationAdmin.class.getName());
        if (sr == null) {
            log.info("Activator: Need ConfigurationAdmin Service to
ensure configuration");
            return;
        }

So if this jackrabbit.server bundle is started before
ConfigurationAdmin, it does not start correctly, yet is shown started
in the OSGi console.

Throwing an Exception instead of log.info would be better already, as
in that case OSGi sees the problem and does not mark the bundle as
started.

There's probably a better way though - how do I tell OSGi that the
jackrabbit.server bundle must be started after the ConfigurationAdmin
service is started?

With SCR I'd add an @scr.reference, but I'm not sure how to do it with
this Activator.

-Bertrand

Re: jackrabbit.server bundle fails if started before ConfigAdmin

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Bertrand

Am Dienstag, den 15.01.2008, 10:43 +0100 schrieb Bertrand Delacretaz:
> Hi Felix,
> 
> On Jan 15, 2008 8:58 AM, Felix Meschberger <fm...@gmail.com> wrote:
> 
> > ...What we can do here, to fix this issue is something likes this:
> > ...   (b) Otherwise a service listener is registered for the Configuration
> > Admin service, which is triggered as soon as the Configuration
> > AdminService is registered. Then the listener may verify the
> > configuration...
> 
> You're right, your changes in SLING-155 solved my problem, thanks!

You are welcome.

> 
> The Jackrabbit repository is now correctly created if usling-webapp is
> started with a non-existing "sling" work directory.
> 
> I thought implementing this would be more complicated: next time I'll
> do it myself ;-)

Welcome to the simple world of OSGi :-)

Regards
Felix


Re: jackrabbit.server bundle fails if started before ConfigAdmin

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Felix,

On Jan 15, 2008 8:58 AM, Felix Meschberger <fm...@gmail.com> wrote:

> ...What we can do here, to fix this issue is something likes this:
> ...   (b) Otherwise a service listener is registered for the Configuration
> Admin service, which is triggered as soon as the Configuration
> AdminService is registered. Then the listener may verify the
> configuration...

You're right, your changes in SLING-155 solved my problem, thanks!

The Jackrabbit repository is now correctly created if usling-webapp is
started with a non-existing "sling" work directory.

I thought implementing this would be more complicated: next time I'll
do it myself ;-)

-Bertrand

Re: jackrabbit.server bundle fails if started before ConfigAdmin

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Am Montag, den 14.01.2008, 17:46 +0100 schrieb Bertrand Delacretaz:
> Hi,
> 
> Currently org.apache.sling.jcr.jackrabbit.server.Activator does this:
> 
>     public void start(BundleContext context) throws Exception {
>         ....
>         ServiceReference sr =
> context.getServiceReference(ConfigurationAdmin.class.getName());
>         if (sr == null) {
>             log.info("Activator: Need ConfigurationAdmin Service to
> ensure configuration");
>             return;
>         }
> 
> So if this jackrabbit.server bundle is started before
> ConfigurationAdmin, it does not start correctly, yet is shown started
> in the OSGi console.

Not really. The bundle activator just tries to ensure at least one
configuration in the Configuration Admin. If there is no Configuration
Admin (yet), this can of course not be done and this is not considered
problematic. In fact, if the Configuration Admin service will never run,
the bundle will never be provided with configuration and never provide
service.

On a side note: We might make this evident by adding a "Import-Service:
ConfigurationAdmin" header to the bundle manifest. This is not enforced
by the framework but highlights the dependency on a running service.

> 
> Throwing an Exception instead of log.info would be better already, as
> in that case OSGi sees the problem and does not mark the bundle as
> started.

No, because as I said, the bundle may well start without the service.

> 
> There's probably a better way though - how do I tell OSGi that the
> jackrabbit.server bundle must be started after the ConfigurationAdmin
> service is started?

There is no way because these are two levels of abstraction: On is the
lifecycle layer which is responsible for the bundle lifecycle and the
other is the service layer providing means to register and retrieve
services.

> 
> With SCR I'd add an @scr.reference, but I'm not sure how to do it with
> this Activator.

What we can do here, to fix this issue is something likes this:

   (a) If the Configuration Admin is available when the bundle starts,
the
       configuration is verified as it is now.
   (b) Otherwise a service listener is registered for the Configuration
Admin
       service, which is triggered as soon as the Configuration Admin
Service
       is registered. Then the listener may verify the configuration
(and
       unregister as a service listener)

WDYT ?

Regards
Felix

> 
> -Bertrand