-
Type:
Bug
-
Resolution: Obsolete
-
Priority:
Medium
-
Component/s: None
-
None
The problem
After importing a customer's Confluence data and fixing its base URL to be 'http://<customer>.jira.com/wiki', I went to JIRA's Application Links page and tried to register an applink in JIRA to the new Confluence, URL 'http://<customer>.jira.com/wiki'.
This failed with the error message 'The specified URL returned a 404 error.':

Not a single line in the JIRA logs. Nothing in the Confluence logs but:
-- referer: http://<customer>.jira.com/wiki/admin/console.action | url: /wiki/admin/editinstances.action | userName: sysadmin 2010-03-31 07:43:37,391 WARN [ajp-j2ee.instance.jirastudio.com-confluence%2F127.0.0.101-8009-1] [studio.core.navbar.NavbarRenderer] getNavbarTopHtml Confluence base URL is unavailable. -- referer: http://<customer>.jira.com/wiki/admin/console.action | url: /wiki/admin/editinstances.action | userName: sysadmin 2010-03-31 07:43:37,392 WARN [ajp-j2ee.instance.jirastudio.com-confluence%2F127.0.0.101-8009-1] [studio.core.navbar.NavbarRenderer] getUserMenuHtml Confluence base URL is unavailable. -- referer: http://<customer>.jira.com/wiki/admin/console.action | url: /wiki/admin/editinstances.action | userName: sysadmin
To replicate:
- Go to Admin -> Wiki -> Configuration -> Application Links and Remove the JIRA applink from Confluence.
- Go to Admin -> Issues -> System -> Application Links
- Remove any existing Confluence applinks (keep the project links)
- Click 'Add Instance' and add a Confluence applink, URL http://<customer>.jira.com/wiki
The cause
The reason for the 404 is that http://<customer>.jira.com/wiki goes through a series of redirects, the last being from
http://<customer>.jira.com/wiki/login.action?os_destination=%2Fhomepage.action
to
http://<customer>.jira.com/wiki/login.jsp?os_destination=%2Fwiki%2Fhomepage.action
The path /wiki/login.jsp doesn't exist, hence the 404. It should be /login.jsp without the /wiki.
Studio apps use the JiraLoginRedirect servlet filter to intercept requests to the application's default login URL (/login.action for Confluence) and redirect the user to JIRA's login. JiraLoginRedirect uses a StudioInfo instance to look up the Studio base URL. DefaultStudioInfo.java has this code:
public String getStudioBaseUrl() { final ApplicationInstances jiras = appLinksManager.getApplicationInstances(Application.JIRA); if (jiras.getPrimary() != null) return jiras.getPrimary().getUrl(); else return getCurrentAppBaseUrl(); }
The else clause is the problem: when running in Confluence, the application base URL is Confluence's, complete with /wiki ending. This is not the same as the Studio base URL. This code is therefore broken for any Confluence that doesn't have a appLinks-JIRA-urls bandana entry, eg:
524289 | _GLOBAL | appLinks-JIRA-urls | <properties>
: <property name="jira" value="http://test.jira.com"/>
: </properties>
The workaround
First add an applink in Confluence, to JIRA. Then you can go to JIRA and add an applink to Confluence, and synchronize.