How to avoid the "Package Error" error in IntelliJ IDEA?

I created a new Maven project using the CQ5 archetype and imported it into IntelliJ IDEA. IntelliJ flagged the use of certain 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 valid error?
  2. How can I fix this (as opposed to disabling verification)?
+10
source share
5 answers

I am using version 12.1.4

  • The error seems legit. I can not find this package in the ACQ 5.6.1 Doc .

  • I will disable the check:

    • Right-click on a block in the right margin.
    • Click "Adjust selection level."
    • Move the slider to the "No" position.
+3
source

Are you exporting these packages as part of a package definition? In the maven project, you should have the maven bundle plugin with <Export-Package>your.packages.here</Export-Package> . Are these packages included in this definition? If not, these services will not actually be available on OSGi.

+3
source

In my case, I accidentally "configured OSGi" when I only wanted to configure Spring. The way I came across this problem is to right-click on the right edge on one of the affected lines by clicking "Adjust selection level" β†’ "Configure checks". I think the hippoLogic solution will save you from all expressions at the syntax level, and also help highlight highlighting at the inspection level. This way you can simply configure the latter to exclude OSGi.

It would be even better to disable OSGi (which I have not explored yet), but here's a quick / dirty fix to reduce selection noise.

+1
source

To fix this check if the corresponding dependencies are present in the pom file, in your case, I think it should be present, since you just imported them from eclipse, where it did not throw any errors. Also check if the settings.xmml parameter is specified correctly, and is in the right place, and the correct one is from intellij. your settings.xml file is present in the maven house or can be represented as a symbolic link in the maven house. Hope this helps.

0
source

I am working on a clone of a project from github, it is not related to OSGI, so I think this is an idea error or I accidentally turned on. Then I assume that the OSGI feature in working on ideas depends on the plugin. Disable the OSGI plugin, the error message will disappear.

on Mac OS:

command + shift + a, type plugin

Search for "OSGI", then disable this plugin.

0
source

Source: https://habr.com/ru/post/973759/


All Articles