OSGi bundle compile error

我的未来我决定 提交于 2019-12-12 03:59:23

问题


When I build my bundle, maven throws the exception:

[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

I use maven-bundle-pluginto build my code:

<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>

And my dependencies are:

<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>

The application running good a few days ago. I think it is the modify of dependency com.onboard.XXX lead to this. But I do not what it is. What shall I do?


回答1:


This appears to be the same question that you asked here with much more information

Your maven-bundle-plugin configuration is exporting the packages from the maven property bundle.Export-Package

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

A bundle should never export a package that it does not contain. In this case your bundle is trying to export about_files and XXX. Both of these things look very wrong.

You haven't included the full POM, nor have you included the osgi.bnd file referenced in your maven-bundle-plugin configuration, but it looks as though this misconfiguration is the source of the error.

In my view trying to automate package exports and private packages with properties is usually a mistake. In a maven module you almost invariably want to private package all of the classes from the src/main/java folder, include the files from src/main/resources and export specific named packages. Incidentally this is how the bnd-maven-plugin works.



来源:https://stackoverflow.com/questions/32458371/osgi-bundle-compile-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!