且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

maven bundle插件生成错误

更新时间:2022-10-14 23:35:04

如果没有POM配置的详细信息,很难确定,但看起来像使用了一个bnd这可能意味着 maven-bundle-plugin 或者 bnd-maven-plugin



在任何一种情况下,正在生成的软件包都会导出一个不在软件包中的软件包。这是一个肯定的方式来打破你的应用程序,所以bnd是无法创建包。

在猜测(因为我没有太多的信息去on)发生以下情况之一:


  • 某人已经重新命名了包中的包,但未更新pom文件中的导出 li>
  • 有人已经从您的pom中删除了一个依赖项,而这个依赖项以前被作为一个静态链接依赖项拉入到您的包中。
  • 有人重构了您正在使用的SNAPSHOT,它不再包含您想要导出的包

  • 有人已经将jar文件嵌入到您的包中,但没有将其添加到包类路径中。
  • 也有可能(但不太可能)某人已经配置你的类不要进入bundle归档的根目录,所以类不是相对于



修正前三个问题很简单,可以修复程序包名称,重新添加正确的依赖关系,或者删除导出。最后两个也很容易解决。你可以像下面这样改变你的bundle classpath:
$ b $ pre $ Bundle-ClassPath:/path/to/my.jar,/ path / to /another.jar,/ path / to / folder

另一个可能更好的选项是不包括嵌套的JAR文件中的代码,而是直接在您的包中嵌入代码。这将意味着调整您的插件配置使用嵌入语法。因为我不知道你使用的是什么插件,所以我不能给你一个例子,但是bnd的include资源的文档是这里


When I run mvn clean install, maven throws the following exception:

Exporting packages that are not on the Bundle-Classpath[Jar:dot]

I could build successfully a few days ago, why is it happenning?

It's hard to be certain without details of your POM configuration, but it looks like you're using a bnd based plugin, which probably means the maven-bundle-plugin or the bnd-maven-plugin.

In either case the bundle that's being produced is exporting a package which is not in the bundle. This is a sure-fire way to break your application, and so bnd is failing the bundle creation.

At a guess (because I don't have much information to go on) one of the following has happened:

  • Somebody has renamed a package in your bundle but not updated the export in the pom file
  • Somebody has removed a dependency from your pom that was previously being pulled into your bundle as a statically linked dependency
  • Somebody refactored a SNAPSHOT that you were using and it no longer contains the package you wanted to export
  • Somebody has embedded a jar file into your bundle, but not added it to the bundle classpath.
  • It is also possible (but less likely) that someone has configured your classes not to go into the root of the bundle archive, so classes are not relative to ..

Fixing the first three issues is easy, either fix the package name, re-add the right dependency, or remove the export. The last two are also fairly easy to fix. You can change your bundle classpath like this:

Bundle-ClassPath: /path/to/my.jar, /path/to/another.jar, /path/to/folder

Another, probably better, option is not to include the code in a nested JAR file, but instead to embed the code directly in your bundle. This would mean adjusting your plugin configuration to use embedding syntax. As I don't know what plugin you're using I can't give you an example, but the documentation for bnd's include resource is here