Visiting the Server Settings page in Bitbucket Server fails with 500 error
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
Visiting the Server Settings page in Bitbucket Server's administration section fails with the following 500 error.
The following error is reported in the atlassian-bitbucket.log
file:
2021-07-02 14:14:59,223 ERROR [http-nio-7990-exec-7] username @7RC99Bx854x19x0 1a1nl9k 137.110.14.234,0:0:0:0:0:0:0:1 "GET /admin/server-settings HTTP/1.1" c.a.s.i.w.HandlerE"ceptionResolverImpl For input string: "7999
"java.lang.NumberFormatException: For input string: "7999
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.base/java.lang.Integer.parseInt(Integer.java:652)
at java.base/java.lang.Integer.parseInt(Integer.java:770)
at com.atlassian.bitbucket.internal.ssh.dao.SshConfigurationDaoImpl.lambda$getConfiguration$0(SshConfigurationDaoImpl.java:57)
at java.base/java.util.Optional.map(Optional.java:265)
at com.atlassian.bitbucket.internal.ssh.dao.SshConfigurationDaoImpl.getConfiguration(SshConfigurationDaoImpl.java:49)
at com.atlassian.bitbucket.internal.ssh.service.DefaultSshConfigurationService.loadConfiguration(DefaultSshConfigurationService.java:237)
at com.atlassian.bitbucket.internal.ssh.service.DefaultSshConfigurationService.getConfiguration(DefaultSshConfigurationService.java:109)
at com.atlassian.bitbucket.internal.ssh.fragments.SshConfigurationFormFragment.doView(SshConfigurationFormFragment.java:61)
at com.atlassian.stash.internal.plugin.PluginFormFragmentsFactoryImpl$PluginFormFragmentsImpl.getViewHtml(PluginFormFragmentsFactoryImpl.java:102)
at com.atlassian.stash.internal.web.admin.ServerSettingsController.showSettings(ServerSettingsController.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)
at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)
at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)
at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)
at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)
at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)
at com.atlassian.bitbucket.internal.ratelimit.servlet.filter.RateLimitFilter.doFilter(RateLimitFilter.java:75)
at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)
at com.atlassian.stash.internal.spring.security.StashAuthenticationFilter.onSuccess(StashAuthenticationFilter.java:219)
at com.atlassian.stash.internal.spring.security.StashAuthenticationFilter.doFilter(StashAuthenticationFilter.java:100)
at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doInsideSpringSecurityChain(BeforeLoginPluginAuthenticationFilter.java:112)
at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:75)
at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:94)
at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:67)
at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)
at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)
at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:94)
at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:67)
at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)
at com.atlassian.plugin.connect.plugin.auth.oauth2.DefaultSalAuthenticationFilter.doFilter(DefaultSalAuthenticationFilter.java:69)
at com.atlassian.plugin.connect.plugin.auth.user.ThreeLeggedAuthFilter.doFilter(ThreeLeggedAuthFilter.java:109)
at com.atlassian.jwt.internal.servlet.JwtAuthFilter.doFilter(JwtAuthFilter.java:37)
at com.atlassian.analytics.client.filter.DefaultAnalyticsFilter.doFilter(DefaultAnalyticsFilter.java:33)
at com.atlassian.analytics.client.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:33)
at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)
at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doBeforeBeforeLoginFilters(BeforeLoginPluginAuthenticationFilter.java:90)
at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:73)
at com.atlassian.stash.internal.request.DefaultRequestManager.doAsRequest(DefaultRequestManager.java:87)
at com.atlassian.stash.internal.hazelcast.ConfigurableWebFilter.doFilter(ConfigurableWebFilter.java:38)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.lang.Thread.run(Thread.java:829)
... 275 frames trimmed
Environment
Bitbucket Server or Data Center version 6.8.2
Cause
There is a blank space next to the SSH port number, making the value be considered a string, and Bitbucket Server fails to format the string value as number, causing the java.lang.NumberFormatException
.
Solution
The SSH port is stored in the database, so in order to update it the following steps should be followed:
Before making any modifications to the database, ensure you have recent working backup of the database that you can restore from if needed.
- Connect to the database using a SQL client
Run this database agnostic SQL command:
UPDATE plugin_setting SET key_value = REPLACE(key_value, '7999 ', '7999') WHERE key_name = 'stash.ssh.settings'
- Restart Bitbucket Server to apply the change