【问题标题】:Deploying an OSGi bundle removes configuration from another one部署一个 OSGi 包会从另一个包中删除配置
【发布时间】:2016-11-01 09:50:08
【问题描述】:

我在 Sling/Felix 中部署了两个 OSGi 包。

Bundle Core 是 Java 代码(OSGi 服务和 Sling 模型),Bundle UI 仅包含 JSP 和 JS 代码,使用 Sling-initial-content 导入到存储库中。

Bundle A 先部署,注册服务,比如放根 URL 来获取应用的图片:

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

这是与该属性关联的类:

@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";

}    

然后我为这个服务的属性添加一个值:

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

但是当我部署 Bundle UI 时,我得到了这个:

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    

为什么要从另一个包中删除配置?这些捆绑包一起工作,但与 Import/Export-Instructions 无关。

我已将 org.apache.sling.installer.provider.jcr 更新到 3.1.18 但还是一样。

可能与https://issues.apache.org/jira/browse/SLING-4925 / https://issues.apache.org/jira/browse/SLING-4929 有关吗?它需要更新 Jackrabbit,我不确定现有内容是否容易。

【问题讨论】:

  • 如何部署其他捆绑包?
  • 我忘了更新这个问题,但在 Sling 邮件列表的帮助下终于找到了问题。另一个包实际上覆盖了 /apps/sling 目录,这就是我的配置被删除的原因。

标签: osgi apache-felix sling


【解决方案1】:

问题在于 UI Bundle 正在部署 JSP 以添加自定义错误页面 (404/403),如下所示:

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

因此,整个 /apps/sling 目录被覆盖并删除了配置。

所以我为此更改了行并解决了问题:

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

【讨论】:

    猜你喜欢
    • 2016-06-06
    • 2018-03-20
    • 1970-01-01
    • 1970-01-01
    • 2016-07-22
    • 2017-08-26
    • 1970-01-01
    • 1970-01-01
    • 2011-10-31
    相关资源
    最近更新 更多