【问题标题】:OSGi bundle compile errorOSGi 包编译错误
【发布时间】:2015-12-04 04:08:20
【问题描述】:

当我构建我的包时,maven 抛出异常:

[ERROR] Bundle com.onboard:com.onboard.service.security:bundle:3.0.0-SNAPSHOT : Exporting packages that are not on the Bundle-Classpath[Jar:dot]: [about_files, XXX]
[ERROR] Error(s) found in bundle configuration

我使用maven-bundle-plugin来构建我的代码:

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.3.7</version>
    <extensions>true</extensions>
    <configuration>
      <manifestLocation>src/main/resources/META-INF</manifestLocation>
      <instructions>
        <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
        <Bundle-Version>${project.version}</Bundle-Version>
        <Export-Package>${bundle.Export-Package};version="${project.version}"</Export-Package>
        <Private-Package>!${bundle.Export-Package};${bundle.Export-Package}.internal.*</Private-Package>
        <_include>osgi.bnd</_include>
      </instructions>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
      <source>1.6</source>
      <target>1.6</target>
    </configuration>
  </plugin>

我的依赖是:

<dependency>
  <groupId>org.eclipse.jetty.orbit</groupId>
  <artifactId>javax.servlet</artifactId>
</dependency>

<dependency>
  <groupId>org.springframework.security</groupId>
  <artifactId>org.springframework.security.web</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>org.springframework.web.servlet</artifactId>
</dependency>

<dependency>
  <groupId>org.elevenframework</groupId>
  <artifactId>org.elevenframework.web.api</artifactId>
</dependency>

<dependency>
  <groupId>com.onboard</groupId>
  <artifactId>com.onboard.domain.model</artifactId>
  <version>${project.version}</version>
</dependency>
<dependency>
  <groupId>com.onboard</groupId>
  <artifactId>com.onboard.service.common</artifactId>
  <version>${project.version}</version>
</dependency>
<dependency>
  <groupId>com.onboard</groupId>
  <artifactId>com.onboard.service.web</artifactId>
  <version>${project.version}</version>
</dependency>
<dependency>
  <groupId>com.onboard</groupId>
  <artifactId>com.onboard.service.account</artifactId>
  <version>${project.version}</version>
</dependency>
<dependency>
  <groupId>com.onboard</groupId>
  <artifactId>com.onboard.service.collaboration</artifactId>
  <version>${project.version}</version>
</dependency>

应用程序在几天前运行良好。我认为这是对依赖com.onboard.XXX 的修改导致了这一点。但我不知道它是什么。我该怎么办?

【问题讨论】:

    标签: osgi apache-felix osgi-bundle


    【解决方案1】:

    这似乎与您向here with much more information提出的问题相同

    您的 maven-bundle-plugin 配置正在从 maven 属性 bundle.Export-Package 导出包

    <Export-Package>${bundle.Export-Package};version="${project.version}"</Export-Package>
    

    一个包应该从不导出一个它不包含的包。在这种情况下,您的包正在尝试导出about_filesXXX。这两件事看起来都很不对劲。

    您没有包含完整的 POM,也没有包含在您的 maven-bundle-plugin 配置中引用的 osgi.bnd 文件,但看起来这个错误配置是错误的根源。

    在我看来,试图自动化包导出和具有属性的私有包通常是一个错误。在 maven 模块中,您几乎总是希望将 src/main/java 文件夹中的所有类私有打包,包括 src/main/resources 中的文件并导出特定命名的包。顺便说一句,这就是bnd-maven-plugin 的工作原理。

    【讨论】:

      猜你喜欢
      • 2012-11-25
      • 2013-02-19
      • 1970-01-01
      • 2013-01-10
      • 2013-06-29
      • 2017-07-29
      • 2021-02-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多