Missing requirement [229.0] osgi.wiring.package; (&(osgi.wiring.package=org.jsoup)(version>=1.9.1))]

Hello I have tried to import a third-party library into osgi framework (jira-plugin server) as I read here on the forum and from atlas tutorials:

My pom:

<!-- Third party lib, must be with compile -->
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.9.1</version>
            <scope>compile</scope> <!-- important! -->
        </dependency>

My import package:

<!-- Add package import here -->
                        <Import-Package>org.springframework.osgi.*;resolution:="optional", org.eclipse.gemini.blueprint.*;resolution:="optional", org.jsoup.*;version="1.9.1", *</Import-Package>

Still, I got this exception:

2019-11-26 10:21:04,766 QuickReload - Plugin Installer ERROR [c.a.p.osgi.factory.OsgiPlugin] Detected an error (BundleException) enabling the plugin ‘com.erstegroup.jira.plugin.andisScraper-tests’ : Unresolved constraint in bundle com.erstegroup.jira.plugin.andisScraper-tests [230]: Unable to resolve 230.0: missing requirement [230.0] osgi.wiring.package; (osgi.wiring.package=com.erstegroup.jira.plugin.andisSync.api) [caused by: Unable to resolve 229.0: missing requirement [229.0] osgi.wiring.package; (&(osgi.wiring.package=org.jsoup)(version>=1.9.1))]. This error usually occurs when your plugin imports a package from another bundle with a specific version constraint and either the bundle providing that package doesn’t meet those version constraints, or there is no bundle available that provides the specified package. For more details on how to fix this, see https://developer.atlassian.com/x/mQAN

As defined on https://developer.atlassian.com/server/framework/atlassian-sdk/managing-dependencies/ :

Packages provided by the container should be added to the <Import-Package> declaration. NOT compile-time third-party dependencies.

Having taken care of the compile time side, we turn our focus to runtime. We need to tell the plugin system what packages to make available to our classloader. This is done with the <Import-Package> instruction.
Assume your plugin requires classes from Confluence’s JSON support, space events, and Lucene mechanisms.

Then, the very next section stipulates:

To use third-party code in your plugin, you need to add a <dependency> just like above, but with an important change:
By specifying <scope>compile</scope> , you tell the SDK that the awesome-utils library is needed at compile time and runtime. The SDK will bundle the awesome-utils library into your plugin, and the plugin system will make it available in the plugin classloader when the plugin is started.

So it seems that you’re using two different method to add dependencies. The container is very unhappy that you’re declaring an <Import-Package> statement but it can’t find that package exported anywhere.

Super, thank you for your answer! Unfortunately I do not get from your answer what is wrong. Would you be so kind to tell what exactly do I miss there? I defined import package and add dependency with compile option. But it actually did not work. The solution was that after I executed atlas-clean. It gets compiled and works again.

I believe you should remove the string org.jsoup.*;version="1.9.1" from the <Import-Package> statement, as your project is containing the package as a compile dependency. The Import Package statement is like saying ‘Hey Jira, give me Jsoup!’ – But Jira doesn’t have Jsoup… Your plugin does.

When I remove it I get another error, now test package is complaining…

Caused by: org.osgi.framework.BundleException: Unable to resolve com.jira.plugin.andisScraper-tests [264](R 264.0): missing requirement [com.jira.plugin.andisScraper-tests [264](R 264.0)] osgi.wiring.package; (osgi.wiring.package=com.jira.plugin.andisSync.api) [caused by: Unable to resolve com.jira.plugin.andisScraper [263](R 263.0): missing requirement [com.jira.plugin.andisScraper [263](R 263.0)] osgi.wiring.package; (osgi.wiring.package=org.jsoup)] Unresolved requirements: [[com.jira.plugin.andisScraper-tests [264](R 264.0)] osgi.wiring.package; (osgi.wiring.package=com.jira.plugin.andisSync.api)]