Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid "The package is not exported by the bundle dependencies" error in IntelliJ IDEA?

I have created a new Maven project using the CQ5 archetype and imported it into IntelliJ IDEA. IntelliJ marks usages of some classes such as org.apache.felix.annotations.Component, org.apache.felix.annotations.Reference, etc. IntellIJ as erroneous with the following error message:

The package is not exported by the bundle dependencies

IntelliJ OSGi Error Message

  1. Is this a legitimate error?
  2. How can I fix it (as opposed to disabling the inspection)?
like image 967
TheFooProgrammer Avatar asked Aug 13 '14 11:08

TheFooProgrammer


3 Answers

Are you exporting those packages as part of the bundle definition? In the maven project, you should have the maven bundle plugin with <Export-Package>your.packages.here</Export-Package> defined. Are these packages included in that definition? If not, those services won't actually be availale in OSGi.

like image 182
Brenn Avatar answered Sep 29 '22 13:09

Brenn


In my case, I accidentally "configured OSGi" when I only wanted to configure Spring. The way I dealt with this issue was by right clicking the right margin at one of the affected lines, clicking "Customize Highlighting Level" --> "Configure Inspections". I think hippoLogic's solution will get rid of all your syntax-level error highlighting as well as helpful inspection-level highlighting. This way you can simply tune the latter to exclude OSGi.

It'd be even better to de-configure OSGi (which I haven't investigated), but here's a quick/dirty fix to reduce the highlighting noise.

like image 43
cognalog Avatar answered Sep 29 '22 14:09

cognalog


I'm using version 12.1.4

  1. The error seems legit. I'm not able to find that package in the ACQ 5.6.1 Doc.

  2. I turn off the inspection by:

    • Right-clicking on the block in the right margin.
    • Click "Customize Highlighting level".
    • Bring the slider down to "None".
like image 35
hippoLogic Avatar answered Sep 29 '22 13:09

hippoLogic