Installing Jira in AWS EC2 using Error Driven Installation

By | April 25, 2020

So you may have heard of test driven development but have you heard of Error Driven Installation? Let me give you an example. Here I will install Jira in AWS using errors to help guide me.

Installing Jira

After you have created your EC2 instance and ssh’d in, download Jira.

wget https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-8.8.0.tar.gz

Then extract it via tar xvf <filename>. eg:

tar xvf atlassian-jira-software-8.8.0.tar.gz

Then try and run it. (in the bin folder of the extracted tar file).

./start-jira.sh

You should get this error:

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

This is good. It means that we need to install Java.

Installing Java

Run the following:

sudo apt-get update
sudo apt install openjdk-8-jre-headless

Then check with:

java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1~18.04-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

Note that later on, I uninstall OpenJDK and install AdoptOpenJDK instead. If you want to save some time, go straight to installing AdoptOpenJDK.

Try starting Jira again

Server startup logs are located in /home/ubuntu/atlassian-jira-software-8.8.0-standalone/logs/catalina.out
Using CATALINA_BASE: /home/ubuntu/atlassian-jira-software-8.8.0-standalone
Using CATALINA_HOME: /home/ubuntu/atlassian-jira-software-8.8.0-standalone
Using CATALINA_TMPDIR: /home/ubuntu/atlassian-jira-software-8.8.0-standalone/temp
Using JRE_HOME: /usr
Using CLASSPATH: /home/ubuntu/atlassian-jira-software-8.8.0-standalone/bin/bootstrap.jar:/home/ubuntu/atlassian-jira-software-8.8.0-standalone/bin/tomcat-juli.jar
Using CATALINA_PID: /home/ubuntu/atlassian-jira-software-8.8.0-standalone/work/catalina.pid
Tomcat started.

You’ll notice that the JRE_HOME path is automatically set. Also, we haven’t set the Jira home directory either but running ./start-jira.sh -fg shows Jira as started.

Open Jira in your browser

Grab your AWS public DNS or the IPv4 Public IP and paste it into a browser and append Jira’s default port of 8080 at the end. You should get an error.

8080 or 80?

If you want to keep the default port of 8080, then you will need to open up port 8080 in your security settings. Go to Security Groups and edit the existing group by adding a “Custom TCP” inbound rule.

This is what it should look like:

Now go back and refresh your browser and you should get a webpage like this:

This is great news because although it is another error, it is progress!

Note, if you get locked out of your SSH and have to log in again, you can kill you Jira running instance by finding the process ID with

ps -ef | grep JIRA

and then running

kill <ID here>

If you want to change the port to 80, then you will have to locate the server.xml file in “atlassian-jira-software-8.8.0-standalone/conf” and then change the Connector port=”8080″ to 80 or another port of your choice. Remember to upgrade your inbound rule to match the port number also.

Configure Jira Home

Next, you want to tell Jira where to make its home. You tell Jira by editing the jira-application.properties at: <jira-application-dir>/atlassian-jira/WEB-INF/classes.

root@ip-172-31-17-239:/home/ubuntu/atlassian-jira-software-8.8.0-standalone/atlassian-jira/WEB-INF/classes# cat jira-application.properties
# Do not modify this file unless instructed. It is here to store the location of the JIRA home directory only and is typically written to by the installer.
jira.home =/home/ubuntu/jirahome

Jira Core setup screen

You should now get these screens

Jira couldn’t create the jira.home directory

If you are getting this error, try running as another user such as sudo.

Setup: JIRA couldn’t create the jira.home directory

Ensure JIRA has permission to create and write to the jira.home directory /home/ubuntu/jirahome.

 

Jira Setup

Here you want to choose “I’ll set it up myself” but what happens is that you should see an error like this:

error on openjdk-8-jre0headless
An Error occurred during ComponentContainerLauncher servlet context initialisation - Assistive Technology not found: org.GNOME.Accessibility.AtkWrapper.
java.awt.AWTError: Assistive Technology not found: org.GNOME.Accessibility.AtkWrapper
 at java.awt.Toolkit.loadAssistiveTechnologies(Toolkit.java:807)

After some messing around, I discovered it was a Java issue so I upgraded to OpenJDK 11 but then I ran into this error:

Starting the JIRA Plugin System _________________
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.felix.framework.ext.ClassPathExtenderFactory$DefaultClassLoaderExtender (file:/home/ubuntu/atlassian-jira-software-8.8.0-standalone/atlassian-jira/WEB-INF/lib/org.apache.felix.framework-5.6.12.jar) to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of org.apache.felix.framework.ext.ClassPathExtenderFactory$DefaultClassLoaderExtender
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

I then decided to change from OpenJDK….

to AdoptOpenJDK,

 

by running:

wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
apt-get update 
apt-get install adoptopenjdk-8-hotspot

Thanks: https://medium.com/adoptopenjdk/adoptopenjdk-rpm-and-deb-files-7003ba38144e

This seemed to resolve the previous error but I then got a memory error.

___ Starting the JIRA Plugin System _________________

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000baaa0000, 136126464, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 136126464 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/ubuntu/atlassian-jira-software-8.8.0-standalone/bin/hs_err_pid4474.log

Trying to disable the plugins:

./start-jira.sh -fg --disable-all-addons --disable-addons=com.atlassian.jira.jira-software-application

resulted in a bootstrap error or a StuckThreadDetectionValve error.

JIRA-Bootstrap ERROR [c.a.jira.startup.DefaultJiraLauncher] JIRA has failed to start because of the following errors: [(Event: Level = (EventLevel: fatal) , Key = (EventType: startup-unexpected) , Desc = We couldn't start JIRA , Exception = An error occurred while trying to start JIRA. We can't give you any more detail right now, we suggest checking the logs for more detail and contacting our support team.<br/>See our documentation for more information on contacting our support team and creating a support zip.), (Event: Level = (EventLevel: fatal) , Key = (EventType: database) , Desc = Could not execute health check, DatabaseConfigurationManager not available. , Exception = ]

WARNING [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.valves.StuckThreadDetectionValve.notifyStuckThreadDetected Thread [http-nio-8080-exec-12] (id=[29]) has been active for [192,700] milliseconds (since [4/25/20 1:08 AM]) to serve the same request for [http://34.217.59.86:8080/secure/SetupDatabase.jspa] and may be stuck (configured threshold for this StuckThreadDetectionValve is [120] seconds). There is/are [1] thread(s) in total that are monitored by this Valve and may be stuck.
	java.lang.Throwable
		at java.lang.Thread.sleep(Native Method)
		at com.atlassian.plugin.util.WaitUntil.invoke(WaitUntil.java:79)

t2.micro free tier doesn’t work for Jira in AWS

With the out of memory errors or other various errors and long wait times, I had to double the memory from 1 GB to 2 GB using a t2.small instance. Note, we are not the free tier anymore!!!!

The plugin system gets started, and boy there are lots, and I can progress to a few more screens

I then paste in my Jira Server (not Jira Data Centre) license key and my admin details but then it stalls and the memory consumed starts building up.

until it nears the limit and then stalls.

 

t2.medium – Success!

I then repeated the process with a t2.medium instance which had 4Gb of RAM and 2 vCPUs. This time….

the memory consumed was about 2.5Gb

Leave a Reply

Your email address will not be published. Required fields are marked *