Cannot retrieve link and provider entity when creating Application Link
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
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.
*Fisheye および Crucible は除く
問題
After creating an Application Link between two Atlassian applications, the link does not appear as configured on one side of the application. This will be encountered when connecting an older Atlassian application to a newer one. For example, creating an Application Link between Fisheye/Crucible 3.10 and Bitbucket Server 4.5 will result in Fisheye/Crucible not displaying the Application Link.
The following error can be seen in the application logs:
2016-05-03 15:04:57,996 ERROR [AppLinks ConcurrentExecutor:thread-9 ] com.atlassian.applinks.core.rest.ui.ListApplicationLinksUIResource ListApplicationLinksUIResource$2$1-callWithContext - Cannot retrieve link and provider entity for Bitbucket (d25a1ac3-6a6d-38cd-a3ab-a87062eaed55) https://bitbucket.company.com
If the creation of the Application Link is attempted again the following error will appear in the UI:
An Application Link to this URL 'https://bitbucket.company.com' has already been configured.
診断
環境
This issue can occur when running an older Atlassian application that comes bundled with Shared Access Layer (SAL) 2.13 and below and a newer application that is running Tomcat 8.0.30+.
- An Atlassian application with SAL 2.13 or below, to check which version of SAL is bundled, see SAL Version Matrix.
- An Atlassian application with Tomcat 8.0.30+, currently the following applications come bundled with Tomcat 8.0.30+:
- Bamboo 5.11+
- Bitbucket Server 4.5 以上
- Confluence 5.9+
- JIRA 7.1.7+
Diagnostic Steps
On the application running SAL 2.13 and below increase the logging level to
DEBUG
for thecom.atlassian.applinks.core.rest.ui.ListApplicationLinksUIResource
class and refresh the Application Link page.Navigate to the Application Link page and the following exception will be present in the logs:
2016-05-03 15:04:57,996 DEBUG [AppLinks ConcurrentExecutor:thread-9 ] com.atlassian.applinks.core.rest.ui.ListApplicationLinksUIResource ListApplicationLinksUIResource$2$1-callWithContext - Exception: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: host must not be null
2016-06-16 22:07:33,930 http-bio-8080-exec-5936 ERROR /rest/applinks/3.0/listApplicationlinkstates/id/e3c165b1-4812-31a9-90e1-e564941e5a52 [core.rest.ui.ApplicationLinkStatesUIResource] Error occurred when retrieving application link state java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: host must not be null at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:192) at com.atlassian.applinks.core.rest.ui.ApplicationLinkStatesUIResource.getApplicationLinkState
- The
Location
header is returned and can also be checked with the commandcurl -i https://bitbucket.company.com
Applications running Tomcat 8.0.29 and below will return the following:
HTTP/1.1 302 Found Server: Apache-Coyote/1.1 Location: https://bitbucket.company.com/projects Transfer-Encoding: chunked Date: Fri, 13 May 2016 19:37:58 GMT
Applications running Tomcat 8.0.30+ will return the following:
HTTP/1.1 302 Found Server: Apache-Coyote/1.1 Location: /projects Transfer-Encoding: chunked Date: Fri, 13 May 2016 19:37:58 GMT
原因
Tomcat 8.0.30 introduced a change that results in the 302 response Location
header being returned to use a relative path. Specifically, this was 56917 which changes this based on the RFC7231 standard. This change in the Location
header triggers a bug in SAL 2.13 and older when it's calling the Apache HTTPClient and results in the Application Link not being displayed.
回避策
The previous behavior of returning the full URL in the Location
header can be changed in Tomcat by doing the following in the application running Tomcat 8.0.30+.
- Stop the application
Modify the
Context
inserver.xml
to add theuseRelativeRedirects
attribute.<Context docBase="${catalina.home}/<atlassian-application>" path="" reloadable="false" useHttpOnly="true" useRelativeRedirects="false" />
The docBase will vary depending on the application. Eg. for JIRA it would be "
${catalina.home}/atlassian-jira
", for Bitbucket Server it would be "${catalina.home}/atlassian-bitbucket
".- Start the application
This should be enough for solving the issue. If you recreate the AppLinks, you should be fine for most use cases but there is an edge-case that could affect Bamboo. Please refer to No application link found for Stash repository: Stash.
ソリューション
Upgrade all Atlassian application to a version that comes bundled with SAL 3.0.1+. Consult the SAL Version Matrix to determine which version to upgrade to.