Bitbucket Server Does Not Start - Failed to construct a URI for the NavBuilder from the current requests
Problem
When running Bitbucket Server up to version 4.x, the application does not start and the following error can be seen immediately after the startup log entries in the atlassian-bitbucket.log
:
2016-11-15 14:18:16,298 INFO [spring-startup] c.a.s.i.server.BuildInfoLogger Starting Bitbucket 4.9.1 (c721a6c built on Wed Aug 31 18:58:59 PDT 2016)
2016-11-15 14:18:16,299 INFO [spring-startup] c.a.s.i.server.BuildInfoLogger JVM: Oracle Corporation OpenJDK 64-Bit Server VM 1.8.0_111-b15
2016-11-15 14:18:16,328 INFO [spring-startup] c.a.s.internal.home.HomeLockAcquirer Successfully acquired lock on home directory /var/atlassian/application-data/bitbucket
2016-11-15 14:18:21,176 INFO [spring-startup] c.a.s.internal.home.HomeLockAcquirer Successfully acquired lock on home directory /var/atlassian/application-data/bitbucket/shared
...
...
...
2016-11-15 15:05:48,485 ERROR [http-nio-7990-exec-8] @19L870Ax905x2513x0 qwhtwm <IP>,<IP> "GET /projects/CEL/avatar.png HTTP/1.1" c.a.s.internal.nav.NavBuilderImpl Failed to construct a URI for the NavBuilder from the current requests. Defaulting to application properties.
java.net.URISyntaxException: Expected closing bracket for IPv6 address at index 14: http://[https://my.domain.com]
at java.net.URI$Parser.fail(URI.java:2848) ~[na:1.8.0_111]
at java.net.URI$Parser.failExpecting(URI.java:2854) ~[na:1.8.0_111]
at java.net.URI$Parser.parseServer(URI.java:3231) ~[na:1.8.0_111]
at java.net.URI$Parser.parseAuthority(URI.java:3155) ~[na:1.8.0_111]
at java.net.URI$Parser.parseHierarchical(URI.java:3097) ~[na:1.8.0_111]
at java.net.URI$Parser.parse(URI.java:3053) ~[na:1.8.0_111]
at java.net.URI.< init>(URI.java:673) ~[na:1.8.0_111]
at com.atlassian.stash.internal.nav.NavBuilderImpl.onRequestStarted(NavBuilderImpl.java:157) ~[classes/:na]
at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:36) [atlassian-event-3.0.0.jar:na]
at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1$1.run(AsynchronousAbleEventDispatcher.java:46) [atlassian-event-3.0.0.jar:na]
at com.google.common.util.concurrent.MoreExecutors$DirectExecutorService.execute(MoreExecutors.java:299) [guava-18.0.jar:na]
at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:105) [atlassian-event-3.0.0.jar:na]
at com.atlassian.event.internal.LockFreeEventPublisher$Publisher.dispatch(LockFreeEventPublisher.java:260) [atlassian-event-3.0.0.jar:na]
at com.atlassian.event.internal.LockFreeEventPublisher.publish(LockFreeEventPublisher.java:102) [atlassian-event-3.0.0.jar:na]
at com.atlassian.stash.internal.event.TransactionAwareEventPublisher.internalPublish(TransactionAwareEventPublisher.java:155) [bitbucket-platform-4.9.1.jar:na]
at com.atlassian.stash.internal.event.TransactionAwareEventPublisher.publish(TransactionAwareEventPublisher.java:99) [bitbucket-platform-4.9.1.jar:na]
at com.atlassian.stash.internal.request.DefaultRequestManager.doAsRequest(DefaultRequestManager.java:78) [bitbucket-service-impl-4.9.1.jar:na]
at com.atlassian.stash.internal.hazelcast.ConfigurableWebFilter.doFilter(ConfigurableWebFilter.java:38) [classes/:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111]
... 36 frames trimmed
Cause
The specific stack trace above was caused by a misconfiguration of the server.xml
This is the most likely cause of such issues, although incorrect proxy rewrites could also cause such issue.
After configuring the instance with a reverse proxy, the Connector was configured this way, which caused the issue:
<Connector port="7990" protocol="HTTP/1.1"
connectionTimeout="20000"
useBodyEncodingForURI="true"
proxyName="https://mydomain.com"
redirectPort="443"
compression="on"
compressableMimeType="text/html,text/xml,text/plain,text/css,application/json,application/javascript,application/x-javascript" />
Resolution
The value for proxyName is incorrect in the configuration above. If you were configuring Bitbucket Server to have a reverse proxy by following one of our docmentation, for example: Securing Bitbucket Server with Apache using SSL, we request you add all these parameters plus the value for proxyName
was incorrect: redirectPort, scheme, proxyName and proxyPort.
Therefore, fixing the configuration above to the one below and restarting the instance fixes the issue:
<Connector port="7990"
protocol="HTTP/1.1"
connectionTimeout="20000"
useBodyEncodingForURI="true"
redirectPort="443"
compression="on"
compressableMimeType="text/html,text/xml,text/plain,text/css,application/json,application/javascript,application/x-javascript"
secure="true"
scheme="https"
proxyName="bitbucket.ultra.me"
proxyPort="443" />