Tip of the Week: Atlassian Connect + Spring Boot Sample

Nov 2, 2016
Aleks Zuevich

Posted by Aleks Zuevich

This sample shows you a basic preview of the Connect framework together with officially supported Atlassian Connect Java framework – Atlassian Connect Spring Boot. You’ll turn a simple web application into an Atlassian Connect add-on and save the input field value associated with JIRA instance. There will be an edit page in the Administration Area and a view page at System Navigation Bar.

To get started with the framework, create a project from the Maven archetype by executing the following command:

mvn archetype:generate -DarchetypeGroupId=com.atlassian.connect -DarchetypeArtifactId=atlassian-connect-spring-boot-archetype -DarchetypeVersion=1.0.0

Maven will ask you to define the groupId, artifactId, and the version for your new project. You will also be asked to specify the Java package for your source code, which by default is the same as your groupId. Once confirmed, Maven will generate the source of a skeleton Atlassian Connect add-on, including:

Let’s modify our server port. Edit application.yml and specify unused port: e.g. add line server.port: 9000.

In order to get an add-on that is running on your personal computer (locally) installed in an Atlassian Cloud instance, you need to make it available on the internet, served over an HTTPS connection. To achieve this, there are many tools you could use, but we use ngrok. ngrok is a simple and free command line tool to tunnel your local development environment to the internet. From the command line, run ngrok http $PORT replacing $PORT with the port used by your add-on (e.g. 9000). Get the HTTPS URL from the command line, as shown in the following image:

Ingrok in java development for Atlassian

Change the add-on’s JSON descriptor (atlassian-connect.json) to set the baseUrl to the ngrok URL from the previous step.

Let’s move on to the business logic and create entity, which represents our input field value associated with JIRA instance:


Then create a repository to work with the entity. Simply extend your repo interface from CrudRepository – no implementation is needed:


We need to update Application class to enable JPA repositories:




And it’s implementation:


Also, we need a controller to handle requests. We map GET /connect-view request to view template, GET /connect-edit to edit template and handle POST /connect-edit request to save the input value:


The Atlassian Connect JavaScript client library establishes a cross-domain messaging bridge between an Atlassian Connect iframe and the host product. All pages to be displayed within an Atlassian product must include a file called all.js, served from the product, in order to establish the bridge and so that to be displayed.

The URL to this file is provided by Atlassian Connect Spring Boot for every request. You would only need to add the following script to your pages:

<script src=”$atlassian-connect-all-js-url” type=”text/javascript”></script>

AUI provides a CDN, which will make your pages load faster and your resources won’t be out of date. In order to serve AUI’s resources from the CDN, you will need to include them in the HEAD of your HTML or template file.

Create reusable header for our two pages (resources/templates/header.vm):


Then create the page to edit the value (resources/templates/edit.vm):


And the page just to view it (resources/templates/view.vm):


Now we just need to describe these pages in the add-on descriptor:


Here we’ve added the View link to the System Top Navigation bar and created “Connect Spring Boot” section with “Edit” link at Admin Plugins Menu:

JIRA menu for ingrok


Run your Spring Boot application and upload the add-on to your Atlassian Cloud Instance.

Actually when I tried to submit the form I faced with the bug ACSPRING-32: I got errors like “Expecting claim ‘qsh’ to have value A but instead it has the value B” at the backend. The reason of this is the Atlassian Connect JavaScript client library doesn’t take into account form-data payload for query string hash computation but Atlassian Connect Spring Boot does. As the result we get 401 status Unauthorized. I’d appreciate you for the vote.

Share this post on:


We are always ready to help you