Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Jira Server/Data Center app: How to add an OOB condition to the web-item module in spring scanner

In this article I will show you how you can add an out of the box Jira condition to a web-item in a Jira Server/Data Center app which uses spring scanner.

You will not have this problem if you do not use spring scanner, but you will if you use. And I will show you two ways how to solve this problem.


I created a Jira Server/Data Center app.

Then I added a new web-item in the atlassian-plugin.xml

<web-item name="my-web-item" i18n-name-key="" key="my--web--item" section="operations-operations" weight="1000">
<description key="my--web--item.description">The my-web-item Plugin</description>
<label key="my--web--item.label"></label>
<condition class="com.atlassian.jira.plugin.webfragment.conditions.IsAdminCondition"/>
<link linkId="my--web--item-link"></link>

This code means that I want to have my-web-item in the view issue screen in the More menu:

Screenshot 2020-09-11 at 19.06.23.png

And also I added a condition to show it only for admins. Here is this line in the atlassian-plugin.xml file:

<condition class="com.atlassian.jira.plugin.webfragment.conditions.IsAdminCondition"/>

You can find the complete code for this part here.

Let's run our app.

And we will see that our app is not installed with the following error:

Caused by: java.lang.ClassNotFoundException: com.atlassian.jira.plugin.webfragment.conditions.IsAdminCondition not found by ru.matveev.alexey.atlassian.jira.condition.tutorial.jira-springscanner-webitem-condition-tutorial [231]

Ok. Let's fix it.

Fix ClassNotFoundException

To fix this error we need to add the com.atlassian.jira.plugin.webfragment.conditions package to the import-package in the pom.xml file.

Now our import-package looks like this:


Now let's run our app again.

And we will see another error:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

It means that the condition class could not inject required beans.

We can fix this error with two methods: add a bean which will imports required beans and use osgi:reference to import required beans.

Method 1: Add a bean which imports required beans

The required beans for our condition are JiraAuthenticationContext and GlobalPermissionService.

That is why I will create src/main/java/ru/matveev/alexey/atlassian/jira/condition/tutorial/impl/

public class BeanInjecter {

public BeanInjecter(@ComponentImport JiraAuthenticationContext jiraAuthenticationContext,
@ComponentImport GlobalPermissionManager globalPermissionManager) {


This bean just injects required beans and it will make those beans visible for our condition as well.

You can find the complete code for this part here.

Now run the app and everything will work.

Method 2: osgi:reference

Another method to use osgi:reference in src/main/resources/META-INF/spring/plugin-context.xml.

I deleted the file which I created earlier.

I added to import-package in pom.xml.

Then I changed src/main/resources/META-INF/spring/plugin-context.xml to the following code:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
<osgi:reference id="globalPermissionManager"

<osgi:reference id="jiraAuthenticationContext"


What I changed there?

I added xmlns:osgi="" and to be able to work with osgi:reference tag. And then I added two osgi:reference tags to import required beans:

 <osgi:reference id="globalPermissionManager"

<osgi:reference id="jiraAuthenticationContext"

That is all.

You can find the complete code for this part here.

Let's run the app and everything works as expected!

1 comment

M Amine Community Leader Jun 04, 2021

Great article


Log in or Sign up to comment
Community showcase
Published in Apps & Integrations

Apps for Confluence you won't want to miss: RSVP for September's Appy Hours

Calling all collaborators and Confluence users! Our Appy Hours event on September 29th features 4 presenters demoing functionality to superpower Confluence. Don't miss learning about these apps i...

117 views 0 9
Read article

Atlassian Community Events