How can I make component, exposed by plugin of type 1, visible to plugin of version 2

I have plugin of type 1. It exposes some component:

<atlassian-plugin key="com.atlassian.jira.plugin.common-plugin" name="Common">
        <description>Common Jira Extension Plugin</description>

    <component key="MyExtendedPropertyStorage" name="Advanced Property Storage"
               class="com.devexperts.jira.propertystorage.DelegatePropertyStorage" public="true">

Then I want to make this component visible to some other plugin of type 2. I've tried to include "Import-Package" to <bundle-instructions> tag, but it didn't help:

&lt;atlassian-plugin key="com.devexperts.jira.plugin.dxdelivery" name="Some plugin of type 2" plugins-version="2"&gt;
        &lt;description&gt;Some plugin of type 2&lt;/description&gt;



When I try to upload this plugin via Plugin Administration web interface, JIRA fails to enable it and I get the following error in logs:

Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.devexperts.jira.plugin.dxdelivery [86]: Unable to resolve 86.0: missing requirement [86.0] package; (package=com.devexperts.jira.propertystorage)
        at org.apache.felix.framework.Felix.resolveBundle(
        at org.apache.felix.framework.Felix.startBundle(
        at org.apache.felix.framework.BundleImpl.start(
        at org.apache.felix.framework.BundleImpl.start(
        at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(
        ... 87 more

Please, help to cope with this problem.

Thanks in advance! Vitaly.

8 answers

0 votes

I hit this a while ago, but quickly got bogged down in trying to work around it. To do so, I think you might actually need to amend some of the core code in Jira and it was starting to look like you'd need two class loaders and a way to make them talk somehow.

I decided it was going to be far more easy to convert the v1 plugin to v2 than persue that any further.

(I was working in 4.2 if that matters)

This plugin v1 is very old and a lot of other v1-plugins depend on it, so it would be very hard and ineffective to convert it to v2.

I definitely need the way to just add dependency from v2 to v1 :(

0 votes

If you definitely can't update the plugins to v2, then I have to say I'd follow up Radu's link - the information there was the route I was going when I realised it was far easier to just convert to v2.

Yeah, I think that would help - I can pick up corresponding classloader and ask it for certain class.

But it seems to be a kind of hack - instead of using Attlassian's plugins system correctly, we use reflection&Ko to hack it :)

Isn't there some kind of the config/bundling-level solution? I mean, some "official" mechanism to say that "Hey, my plugin v2 would need that specific component from main classloader. Dear OSGI, pick-up it for me, please".

I am almost sure that such solution should exist because java.* and core atlassian classes (and lot more) are available in any v2 plugin. Therefore, OSGI was told about them somehow :)

1. I do not force anybody to use it ;)

2. "I am almost sure that such solution should exist because java.* and core atlassian classes (and lot more) are available in any v2 plugin. Therefore, OSGI was told about them somehow" - that's normal, because it is how Jira bundles Felix. Check it out in their sources ...


If you'd like some development help to just handle this and any others in your system in question without the headache, we can help you get this done fast.


0 votes

Although not impossible, this would be A LOT of work.

Basically your V1 component is added to an internal spring container and gets all of it's dependencies injected, but sinces it's not an OSGi bundle, it is not aware of the OSGi container and visaversa.

In a V2 plugin, the component is also added to a spring container AND since it's an OSGi bundle, spring has the ability to expose the components to other OSGi bundles.

So essentially, the only way you could make OSGi aware of your V1 plugin component would be to write a V2 plugin with the V1 plugin as a dependency (at build time), then write an OSGi Bundle Activator to load your V1 class and expose it as a service. However, if your V1 component has dependencies injected, you're gonna face a how lot of headaches to get all of the dependencies exposed as well.

At that point, it would be easier to just maintain a V1 and V2 version of your plugin rather than writing a complicated wrapper that's really fragile.

As for core JIRA, we have a special HostComponentProvider that takes care of mapping core components to OSGi services, but it's a part of JIRA and so we have access to a lot of low-level spring/OSGi framework code to make it happen.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

441 views 8 26
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you