Trusted Application Authentication IPv6 Exception
Symptoms
While trying to set up an Application Link between JIRA and Bitbucket Server using Trusted Applications, the following exception is logged in atlassian-bitbucket.log
:
SEVERE: Servlet.service() for servlet [default] in context with path [] threw exception
java.lang.IllegalArgumentException: '0:0:0:0:0:0:0:1%0' is not an IP string literal.
at com.atlassian.ip.InetAddresses.forString(InetAddresses.java:64)
at com.atlassian.ip.IPMatcher.matches(IPMatcher.java:46)
at com.atlassian.security.auth.trustedapps.AtlassianIPMatcher.match(AtlassianIPMatcher.java:51)
at com.atlassian.security.auth.trustedapps.DefaultRequestValidator.validateRemoteRequestIP(DefaultRequestValidator.java:34)
at com.atlassian.security.auth.trustedapps.DefaultRequestValidator.validate(DefaultRequestValidator.java:26)
at com.atlassian.security.auth.trustedapps.DefaultTrustedApplication.checkRequest(DefaultTrustedApplication.java:117)
at com.atlassian.security.auth.trustedapps.DefaultTrustedApplication.decode(DefaultTrustedApplication.java:88)
at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationFilterAuthenticator.authenticate(TrustedApplicationFilterAuthenticator.java:102)
This happens when trying to view the Source tab on a JIRA issue which displays a HTTP 500 error.
Cause
Currently, application links can exhibit some incorrect behavior when IPv6 is enabled due to the way Java deals with IPv6:
Resolution
Users can force Java to use IPv4 by adding by appending
-Djava.net.preferIPv4Stack=true
toJVM_REQUIRED_ARGS
orJVM_SUPPORT_RECOMMENDED_ARGS
in<Bitbucket Server installation directory>/bin/setenv.sh
setenv and environment variable changes in Bitbucket Server 5.0+
Starting with Bitbucket Server 5.0, setenv.sh
and setenv.bat
have been removed. The options that were set in this file can now be set via environment variables. Where to set the environment variable depends on which Operating System you're running on.
Linux
When using the atlbitbucket
service on Linux, the environment variables are ignored. You must set the parameters in _start-webapp.sh (or start-bitbucket.sh)
. These values will be read when the service starts.
As an example, to set JVM_SUPPORT_RECOMMENDED_ARGS
, you would add this line to the file:
JVM_SUPPORT_RECOMMENDED_ARGS=-XX:+HeapDumpOnOutOfMemoryError
Windows
Set the parameter as an environment variable for the user running Bitbucket Server. For example, if you want to set JVM_SUPPORT_RECOMMENDED_ARGS
, create it as an environment variable and assign the appropriate value to it. When Bitbucket Server starts using the startup scripts or service, it will pick up and apply this value.