Maven Bundle Plugin: Export has private references
Asked Answered
M

1

16

After updating the maven-bundle-plugin from version 2.3.5 to version 2.4.0 running mvn clean install outputs some warning messages, which I don't fully understand. E.g.

Export ch.entwine.weblounge.contentrepository.impl.index, has 1, private references [org.elasticsearch.action.bulk]

I guess this has something to do with an embedded lib (elasticsearch). Here are parts of the POM:

<dependencies>
  ...
  <dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>0.19.9</version>
  </dependency>
  ...
</dependencies
...
<Export-Package>
  ...
  ch.entwine.weblounge.contentrepository.impl.index
  ...
</Export-Package>
<Embed-Dependency>
  ....
  elasticsearch;inline=true
  ...
</Embed-Dependency>

What does the error message exactly mean? What is the recommended way to solve such problems?

Metatherian answered 19/1, 2014 at 14:55 Comment(0)
O
24

That message means that inside one of your public packages (that you are exporting) there is a class that is accessing a class that is in a private package (a package that is not being exported).

When embedding jars you must not use Export-Package to declare packages from the embedded jars. it is for you declare the packages from the own bundle. You must use <_exportcontents> to export org.elasticsearch.action.bulk.

Overstate answered 20/1, 2014 at 11:45 Comment(2)
Thanks for your answer, it works! But I was always thinking that packages from embedded dependencies should not be exported (not be part of the bundle api). Am I wrong on this?Metatherian
well, that depends... if you are embedding a jar is because it doesn't exists as a bundle, so you can't set it scope as "provided". so the best is to export all packages that contain classes that your public methods will need. this message normally is a indication of a future classloading issue...Overstate

© 2022 - 2024 — McMap. All rights reserved.