1
votes

I have two OSGi bundles that I deploy in Sling/Felix.

Bundle Core is Java code (OSGi Services and Sling models), Bundle UI contains only JSPs and JS code, imported in the repository using Sling-initial-content.

Bundle A is deployed first, registers services, for instance, put the root URL to get images for the application:

[c.r.o.c.services.models.components.ImageComponentServiceImpl,1410] ServiceEvent REGISTERED

Here is the associated class with the property:

@Component(metatype=true, label="Image component service", description="Service providing data to image components")
@Service(value = ImageComponentService.class)
public class ImageComponentServiceImpl extends AbstractModelService implements ImageComponentService {

  @Property(label="Images root URL", description="URL to the web directory containing image files")
  public static final String IMAGE_ROOT_URL = "image.root.url";

}    

Then I add a value to the property on this service:

INFO  c.r.o.c - Service [c.r.o.c.services.models.components.ImageComponentServiceImpl,1410] ServiceEvent UNREGISTERING
INFO  c.r.o.c - Service [c.r.o.c.services.models.components.ImageComponentServiceImpl,1451] ServiceEvent REGISTERED

But when I deployed the Bundle UI I get this:

INFO  o.a.s.i.p.jcr.impl.JcrInstaller - Removing resource from OSGi installer: [/apps/sling/install/c.r.o.c.services.models.components.ImageComponentServiceImpl.config]
INFO  o.a.s.i.p.jcr.impl.JcrInstaller - Deleting WatchedFolder:/apps/sling/install, path does not exist anymore
INFO  o.apache.sling.audit.osgi.installer - Deleted configuration c.r.o.c.services.models.components.ImageComponentServiceImpl from resource TaskResource(url=jcrinstall:/apps/sling/install/c.r.o.c.services.models.components.    ImageComponentServiceImpl.config, entity=config:c.r.o.c.services.models.components.ImageComponentServiceImpl, state=UNINSTALL, attributes=[service.pid=c.r.o.c.services.models.components.ImageComponentServiceImpl, resource.uri    .hint=c.r.o.c.services.models.components.ImageComponentServiceImpl], digest=5474257d3971e3f9a92ac39b2f2d4b69)
INFO  c.r.o.c - Service [c.r.o.c.services.models.components.ImageComponentServiceImpl,1451] ServiceEvent UNREGISTERING
INFO  c.r.o.c - Service [c.r.o.c.services.models.components.ImageComponentServiceImpl,1452] ServiceEvent REGISTERED    

Why is it removing the configuration from the other bundle? Those bundles work together but are not related by Import/Export-Instructions.

I have updated org.apache.sling.installer.provider.jcr to 3.1.18 but it's the same.

Could it be related to https://issues.apache.org/jira/browse/SLING-4925 / https://issues.apache.org/jira/browse/SLING-4929 ? It requires to update Jackrabbit and I'm not sure it's easy with existing content.

1
How do you deploy the other bundle? - Robert Munteanu
I forgot to update this question but finally found the problem with the help of Sling mailing-list. The other bundle was actually overwriting the /apps/sling directory, that's why my configuration was deleted. - Guillaume Lucazeau

1 Answers

1
votes

The problem was that the UI Bundle was deploying JSPs to add custom error pages (404/403), like this:

<Sling-Initial-Content>
  SLING-INF/content/apps/sling;overwrite:=true;uninstall=true
</Sling-Initial-Content>

Therefore, the whole /apps/sling directory was overwritten and configuration removed.

So I've changed the line for this and it fixed the issue:

<Sling-Initial-Content>
  SLING-INF/content/apps/sling/servlet;path:=/apps/sling/servlet;overwrite:=true;uninstall=true
</Sling-Initial-Content>