Login into Bamboo fails due to broken Captcha image with FontConfiguration error

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Bamboo chart gadgets throw Java Null Pointer Exceptions (NPE) or fail with FontConfiguration errors when installed on Linux operating systems with AdoptOpenJDK.

Environment

Bamboo 7 and later

Linux

Diagnosis

You will see the following error in the atlassian-bamboo.log log file when users are trying to login into Bamboo:

2021-02-10 12:50:05,151 ERROR [http-nio-8080-exec-22] [FiveOhOh] 500 Exception was thrown.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'imageCaptchaService' defined in class path resource [applicationContextCaptcha.xml]: Cannot resolve reference to bean 'captchaEngine' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'captchaEngine' defined in class path resource [applicationContextCaptcha.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.octo.captcha.engine.image.gimpy.DefaultGimpyEngine]: Constructor threw exception; nested exception is java.lang.NullPointerException
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:314)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolve
18:25:49 From skale to Everyone : from server
18:26:46 From skale to Everyone : Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'captchaEngine' defined in class path resource [applicationContextCaptcha.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.octo.captcha.engine.image.gimpy.DefaultGimpyEngine]: Constructor threw exception; nested exception is java.lang.NullPointerException
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1302)


Cause

AdoptOpenJDK does not include a font configuration package, required by the Bamboo captcha feature.

Solution

It is important to check the atlassian-bamboo.log file for the Java Null Pointer Exception below, then first try the solution outlined in Captcha not showing after a couple of failed attempts:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.octo.captcha.engine.image.gimpy.DefaultGimpyEngine]: Constructor threw exception; nested exception is java.lang.NullPointerException
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:184)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1294)
        ... 192 more
Caused by: java.lang.NullPointerException
        at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)
        at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:219)

The reason why you need to disable the captcha as mentioned in the document is that by doing so the end-users will be able to log in again without issues. However for security reasons, if you do not want to disable the captcha, then to solve this problem, install fontconfig (or an equivalent), and then restart Bamboo. Refer to the documentation for your Linux distribution or preferred package manager for information on how to do this.

Here are the commands to install font dependency in a number of common Linux distributions and package managers. Your mileage will vary.

Ubuntu 

sudo apt install -y fontconfig

CentOS

CentOS 7 does not work with fontconfig. You can install dejavu-sans-fonts as an alternative:

sudo yum install -y dejavu-sans-fonts

RHEL 

sudo yum install fontconfig
On RHEL 6, it might be necessary to install both the dejavu-sans-fonts and the fontconfig packages:
sudo yum install fontconfig dejavu-sans-fonts

Debian

apt-get update && apt-get install -y fontconfig

Fedora

dnf install -y fontconfig

Once you finish the fontconfig or equivalent installation, please restart Bamboo.

Last modified on Feb 8, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.