Skip to content

Commit

Permalink
DCPERF-432 Install fonts required by JDK
Browse files Browse the repository at this point in the history
TDD: green

Avoid errors like

```
java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:42)
	at com.atlassian.diagnostics.internal.platform.monitor.event.EventSystemMonitor.invokeMonitored(EventSystemMonitor.java:105)
	at com.atlassian.diagnostics.internal.platform.monitor.event.MonitoredListenerInvoker.invoke(MonitoredListenerInvoker.java:38)
	at com.atlassian.event.internal.ComparableListenerInvoker.invoke(ComparableListenerInvoker.java:48)
	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.lambda$null$0(AsynchronousAbleEventDispatcher.java:37)
	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:85)
	at com.atlassian.diagnostics.internal.platform.monitor.event.MonitoredEventDispatcher.dispatch(MonitoredEventDispatcher.java:36)
	at com.atlassian.event.internal.EventPublisherImpl.publish(EventPublisherImpl.java:114)
	at com.atlassian.event.internal.LockFreeEventPublisher.publish(LockFreeEventPublisher.java:40)
	at com.atlassian.plugin.event.impl.DefaultPluginEventManager.broadcast(DefaultPluginEventManager.java:90)
	at com.atlassian.plugin.manager.DefaultPluginManager.broadcastIgnoreError(DefaultPluginManager.java:1963)
	at com.atlassian.plugin.manager.DefaultPluginManager.lambda$earlyStartup$5(DefaultPluginManager.java:533)
	at com.atlassian.plugin.manager.PluginTransactionContext.wrap(PluginTransactionContext.java:63)
	at com.atlassian.plugin.manager.DefaultPluginManager.earlyStartup(DefaultPluginManager.java:527)
	at com.atlassian.jira.plugin.JiraPluginManager.earlyStartup(JiraPluginManager.java:127)
	at com.atlassian.jira.component.pico.ComponentManager$PluginSystem.earlyStartup(ComponentManager.java:679)
	at com.atlassian.jira.component.pico.ComponentManager.earlyStartPluginSystem(ComponentManager.java:245)
	at com.atlassian.jira.upgrade.PluginSystemLauncher.start(PluginSystemLauncher.java:48)
	at com.atlassian.jira.startup.DefaultJiraLauncher.lambda$postDbLaunch$2(DefaultJiraLauncher.java:153)
	at com.atlassian.jira.config.database.DatabaseConfigurationManagerImpl.doNowOrEnqueue(DatabaseConfigurationManagerImpl.java:305)
	at com.atlassian.jira.config.database.DatabaseConfigurationManagerImpl.doNowOrWhenDatabaseActivated(DatabaseConfigurationManagerImpl.java:202)
	at com.atlassian.jira.startup.DefaultJiraLauncher.postDbLaunch(DefaultJiraLauncher.java:144)
	at com.atlassian.jira.startup.DefaultJiraLauncher.lambda$start$0(DefaultJiraLauncher.java:109)
	at com.atlassian.jira.util.devspeed.JiraDevSpeedTimer.run(JiraDevSpeedTimer.java:31)
	at com.atlassian.jira.startup.DefaultJiraLauncher.start(DefaultJiraLauncher.java:107)
	at com.atlassian.jira.startup.LauncherContextListener.initSlowStuff(LauncherContextListener.java:162)
	at com.atlassian.jira.startup.LauncherContextListener.initSlowStuffInBackground(LauncherContextListener.java:147)
	at com.atlassian.jira.startup.LauncherContextListener.contextInitialized(LauncherContextListener.java:105)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4007)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4448)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:749)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:721)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:749)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:211)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:415)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:878)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:735)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473)
Caused by: io.atlassian.util.concurrent.LazyReference$InitializationException: java.lang.InternalError: java.lang.reflect.InvocationTargetException
	at io.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:156)
	at io.atlassian.util.concurrent.LazyReference.get(LazyReference.java:116)
	at io.atlassian.util.concurrent.ResettableLazyReference.get(ResettableLazyReference.java:95)
	at com.atlassian.jira.servlet.JiraCaptchaServiceImpl.getInstance(JiraCaptchaServiceImpl.java:29)
	at com.atlassian.jira.servlet.JiraCaptchaServiceImpl.getImageCaptchaService(JiraCaptchaServiceImpl.java:33)
	at com.atlassian.jira.bc.security.login.CaptchaValidatorImpl.<init>(CaptchaValidatorImpl.java:21)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at org.picocontainer.injectors.AbstractInjector.newInstance(AbstractInjector.java:145)
	at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:342)
	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
	at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
	at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
	at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
	at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
	at com.atlassian.jira.component.pico.behaviors.ContainerSynchronizedBehavior.getComponentInstance(ContainerSynchronizedBehavior.java:26)
	at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:698)
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:646)
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:677)
	at com.atlassian.jira.component.pico.CachingMutablePicoContainer.getComponent(CachingMutablePicoContainer.java:139)
	at com.atlassian.jira.component.pico.ComponentContainer.getComponentInstance(ComponentContainer.java:326)
	at com.atlassian.jira.component.pico.osgi.OsgiServiceRegistry.addRegisteredSingletonServices(OsgiServiceRegistry.java:110)
	at com.atlassian.jira.component.pico.osgi.OsgiServiceRegistry.getServices(OsgiServiceRegistry.java:98)
	at com.atlassian.jira.component.pico.osgi.JiraHostComponentProvider.provide(JiraHostComponentProvider.java:50)
	at com.atlassian.plugin.osgi.container.felix.FelixOsgiContainerManager.collectHostComponents(FelixOsgiContainerManager.java:484)
	at com.atlassian.plugin.osgi.container.felix.FelixOsgiContainerManager.start(FelixOsgiContainerManager.java:232)
	at com.atlassian.plugin.osgi.container.felix.FelixOsgiContainerManager.onStart(FelixOsgiContainerManager.java:200)
	... 62 more
Caused by: java.lang.InternalError: java.lang.reflect.InvocationTargetException
	at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:87)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
	at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:75)
	at java.desktop/java.awt.Font.getFont2D(Font.java:526)
	at java.desktop/java.awt.Font.canDisplay(Font.java:2202)
	at com.octo.captcha.component.image.fontgenerator.RandomFontGenerator.checkFontCanDisplayCharacters(RandomFontGenerator.java:223)
	at com.octo.captcha.component.image.fontgenerator.RandomFontGenerator.cleanFontList(RandomFontGenerator.java:179)
	at com.octo.captcha.component.image.fontgenerator.RandomFontGenerator.initializeFonts(RandomFontGenerator.java:94)
	at com.octo.captcha.component.image.fontgenerator.RandomFontGenerator.<init>(RandomFontGenerator.java:81)
	at com.atlassian.jira.servlet.CensoredCaptchaEngine.createFontGenerator(CensoredCaptchaEngine.java:87)
	at com.atlassian.jira.servlet.CensoredCaptchaEngine.createWord2Image(CensoredCaptchaEngine.java:66)
	at com.atlassian.jira.servlet.CensoredCaptchaEngine.buildInitialFactories(CensoredCaptchaEngine.java:49)
	at com.octo.captcha.engine.image.ListImageCaptchaEngine.<init>(ListImageCaptchaEngine.java:24)
	at com.atlassian.jira.servlet.CensoredCaptchaEngine.<init>(CensoredCaptchaEngine.java:40)
	at com.atlassian.jira.servlet.JiraImageCaptchaServiceImpl.<clinit>(JiraImageCaptchaServiceImpl.java:13)
	at com.atlassian.jira.servlet.JiraCaptchaServiceImpl$1.create(JiraCaptchaServiceImpl.java:19)
	at com.atlassian.jira.servlet.JiraCaptchaServiceImpl$1.create(JiraCaptchaServiceImpl.java:16)
	at io.atlassian.util.concurrent.ResettableLazyReference$InternalReference.create(ResettableLazyReference.java:185)
	at io.atlassian.util.concurrent.LazyReference$Sync.run(LazyReference.java:332)
	at io.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:150)
	... 91 more
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:85)
	... 110 more
Caused by: java.lang.RuntimeException: Fontconfig head is null, check your fonts or fonts configuration
	at java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1269)
	at java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:224)
	at java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.java:106)
	at java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:706)
	at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:358)
	at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:315)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
	at java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:315)
	at java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35)
	at java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:56)
	... 116 more
```
  • Loading branch information
mgrzaslewicz committed Jun 19, 2024
1 parent 99420df commit bd102d7
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 4 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ Adding a requirement of a major version of a dependency is breaking a contract.
Dropping a requirement of a major version of a dependency is a new contract.

## [Unreleased]
[Unreleased]: https://github.com/atlassian/infrastructure/compare/release-4.29.1...master
[Unreleased]: https://github.com/atlassian/infrastructure/compare/release-4.29.2...master

### Fixed
- Install fonts required by `AdoptOpenJDK`, `AdoptOpenJDK11`, `OracleJDK`, `VersionedOracleJdk`. Aid DCPERF-432.

## [4.29.2] - 2024-06-19
[4.29.1]: https://github.com/atlassian/infrastructure/compare/release-4.29.1...release-4.29.2

### Fixed
- Fix remote JVM debugger setup for Jira. Aid DCPERF-432.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class AdoptOpenJDK : VersionedJavaDevelopmentKit {
download(connection)
connection.execute("tar -xzf $jdkArchive")
connection.execute("echo '${use()}' >> ~/.profile")
JdkFonts().install(connection)
}

override fun use(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class AdoptOpenJDK11 : VersionedJavaDevelopmentKit {
download(connection)
connection.execute("tar -xzf $jdkArchive")
connection.execute("echo '${use()}' >> ~/.profile")
JdkFonts().install(connection)
}

override fun use(): String =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.atlassian.performance.tools.infrastructure.api.jvm

import com.atlassian.performance.tools.infrastructure.api.os.Ubuntu
import com.atlassian.performance.tools.ssh.api.SshConnection

internal class JdkFonts {

/**
* @see <a href="https://confluence.atlassian.com/jirakb/jira-server-7-13-or-later-fails-with-fontconfiguration-error-when-installing-on-linux-operating-systems-964956221.html">Jira fonts installation</a>
* @see <a href="https://jira.atlassian.com/browse/CONFSRVDEV-8954">Captcha failing to load because of missing fonts</a>
*/
fun install(ssh: SshConnection) {
Ubuntu().install(ssh, listOf("fontconfig"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.apache.logging.log4j.Logger
import java.net.URI
import java.time.Duration


class OracleJDK : VersionedJavaDevelopmentKit {
private val logger: Logger = LogManager.getLogger(this::class.java)
private val jdkUpdate = 131
Expand All @@ -29,6 +28,7 @@ class OracleJDK : VersionedJavaDevelopmentKit {
download(connection)
connection.execute("tar -xzf $jdkArchive")
connection.execute("echo '${use()}' >> ~/.profile")
JdkFonts().install(connection)
}

override fun use(): String = "export PATH=$jreBin:$bin:${'$'}PATH; export JAVA_HOME=$path"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class VersionedOracleJdk private constructor(
}.retry(3, ExponentialBackoff(ofSeconds(10)))
connection.execute("tar --extract --gunzip --file jdk-$version.tar.gz")
connection.execute("echo '${use()}' >> ~/.profile")
JdkFonts().install(connection)
}

override fun use(): String = "export PATH=$javaHome/bin:\$PATH; export JAVA_HOME=$javaHome"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ class AdoptOpenJdk11IT {
fun shouldHaveJavaHomeSet() {
JdkSupport(AdoptOpenJDK11()).shouldHaveJavaHomeSet("/jdk-11.0.1+13")
}

@Test
fun shouldLoadFont() {
JdkSupport(AdoptOpenJDK11()).shouldLoadFont()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ class AdoptOpenJdkIT {
fun shouldSupportJstat() {
JstatSupport(AdoptOpenJDK()).shouldSupportJstat()
}

@Test
fun shouldHaveJavaHomeSet() {
JdkSupport(AdoptOpenJDK()).shouldHaveJavaHomeSet("/jdk8u172-b11")
}

@Test
fun shouldLoadFont() {
JdkSupport(AdoptOpenJDK()).shouldLoadFont()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ class OpenJdk11IT {
fun shouldHaveJavaHome() {
JdkSupport(OpenJDK11()).shouldHaveJavaHomeSet("/usr/lib/jvm/java-1.11.0-openjdk-")
}
}

@Test
fun shouldLoadFont() {
JdkSupport(OpenJDK11()).shouldLoadFont()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ class OpenJdkIT {
fun shouldHaveJavaHome() {
JdkSupport(OpenJDK()).shouldHaveJavaHomeSet("/usr/lib/jvm/java-1.8.0-openjdk-")
}
}

@Test
fun shouldLoadFont() {
JdkSupport(OpenJDK()).shouldLoadFont()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ class OracleJdkIT {
fun shouldHaveJavaHomeSet() {
JdkSupport(OracleJDK()).shouldHaveJavaHomeSet("/jdk1.8.0_131")
}

@Test
fun shouldLoadFont() {
JdkSupport(OracleJDK()).shouldLoadFont()
}

}

0 comments on commit bd102d7

Please sign in to comment.