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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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!



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

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

217 views 2 5
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you