Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

UnsatisfiableDependenciesException when injecting plugin classes into CustomFieldSearcher

Kristin Hreinsdottir [Tempo] July 2, 2012

Hi

With good help from the JIRA source (VersionSearcher and others) I am modifying a CustomFieldSearcher to implement CustomFieldStattable to be able to use the Custom Field in the Two Dimensional Filter Gadget. I need to inject one of my plugin classes into the Searcher but it seems to be impossible. I always end up with UnsatisfiableDependenciesException.

I found this link: https://developer.atlassian.com/display/DOCS/Plugin+and+Gadget+Gotchas and tried everything suggested there but nothing works. Injecting JIRA classes works without problems.

The class I am trying to inject is defined in atlassian-plugin.xml as a Component module. Since this component is part of the same plugin as the searcher I dont understand why this isn't working!

Does anyone have a clue!

Kind regards

Kristín

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Wojciech Seliga
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 22, 2013

That's almost certainly a bug in JIRA.

I raised it at https://jira.atlassian.com/browse/JRA-31413

Here is for your convenience the workaround I used successfuly a few times in the past:

  • define you dependency as a public module (public to OSGi) in your plugin
  • do NOT attempt to inject it to your CustomFieldSearcher implementation constructor
  • instead in init(CustomField) method use ComponentAccessor.getOSGiComponentInstanceOfType(YourDependencyClass.class) and assign it to a field for future use.

1 vote
David Thompson November 29, 2012

Kristin,

I just ran into this exact same problem as you. What a pain. Don't know if you ever got this solved--but what I believe is happening is that the classloader can't find the component even though its in the same classloader (I believe this is a bug.)

I do have a work-around for you if you are still trying to solve this. Here's how I did it-- in my atlassian-plugin.xml file I have the following:

<component key="itemManager" class="org.safmt.jira.items.util.impl.ConfigurationItemManagerImpl"
     interface="org.safmt.jira.items.util.ItemManager"/>
<customfield-type name="Multi Item Picker" i18n-name-key="multi-item-picker.name" key="multi-item-picker" class="org.safmt.jira.plugin.customfields.MultiItemPicker">
    <description key="multi-item-picker.description">The Multi Item Picker Plugin</description>
    <resource type="velocity" name="view" location="templates/plugins/fields/view/view-multiitem.vm"/>
    <resource type="velocity" name="column-view" location="templates/plugins/fields/view/column-view-multiitem.vm"/>
    <resource type="velocity" name="edit" location="templates/plugins/fields/edit/edit-multiitem.vm"/>
    <resource type="velocity" name="xml" location="templates/plugins/fields/xml/xml-multiitem.vm"/>
  </customfield-type>
  <customfield-searcher name="MultiItem Free Text Searcher" key="multi-item-searcher" class="org.safmt.jira.issue.customfields.searchers.MultiItemPickerSearcher">
    <description key="admin.customfield.searcher.textsearcher.desc">The MultiItem Text Searcher Plugin</description>
    <valid-customfield-type package="${project.groupId}.${project.artifactId}" key="multi-item-picker"/>
    <resource type="velocity" name="search" location="templates/plugins/fields/editsearcher/search-basictext.vm"/>
    <resource type="velocity" name="view" location="templates/plugins/fields/viewsearcher/view-searcher-basictext.vm"/>
    <resource type="velocity" name="label" location="templates/plugins/fields/viewsearcher/label-searcher-basictext.vm"/>
  </customfield-searcher>


The customfield-searcher can't injext the itemManager. But in my constructor of the Searcher, I did the following get access to the itemManager:

public MultiItemPickerSearcher(
//          final ItemManager itemManager,
          FieldVisibilityManager fieldVisibilityManager,
          JqlOperandResolver jqlOperandResolver,
          OperatorUsageValidator usageValidator,
          CustomFieldInputHelper customFieldInputHelper,
          CustomFieldManager customFieldManager,
          SearchHandlerManager searchHandlerManager,
          FieldConfigSchemeManager fieldConfigSchemeManager,
          ApplicationLinkService entityLinkService
            ) throws ClassNotFoundException {
        ComponentClassManager ccm = ComponentAccessor.getComponentClassManager();
        this.itemManager = ccm.newInstance("org.safmt.jira.items.util.impl.ConfigurationItemManagerImpl");
//        this.itemManager = itemManager;
        this.fieldVisibilityManager = fieldVisibilityManager;
        this.jqlOperandResolver = jqlOperandResolver;
        this .customFieldInputHelper = customFieldInputHelper;
        this.customFieldManager = customFieldManager;
        this.searchHandlerManager = searchHandlerManager;
        this.fieldConfigSchemeManager = fieldConfigSchemeManager;
    }

Since I found a work-around--would you mind filling out the bug report with Atlassian?

0 votes
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 2, 2012

Did you make it public? Consutructor injection is supported only for public components in JIRA I believe.

Kristin Hreinsdottir [Tempo] July 2, 2012

Yes I tried that too with no luck. I don't think it needs to be public though, its just if you want other plugins to be able to import your component. See documentation:

https://confluence.atlassian.com/display/JIRA043/Component+Plugin+Module#

TAGS
AUG Leaders

Atlassian Community Events