Issue 1898: Exception in openBrowser thrown when installing Gerrit on a headless machine
Status:  Submitted
Owner: ----
Closed:  May 2013
Reported by matt...@unsolvable.org, May 3, 2013
Affected Version: 2.6-rc1
The problem was not present in 2.5.2.

What steps will reproduce the problem?
Perform a fresh Gerrit install, using a command line: java -jar /path/to/gerrit-2.6-rc1.war init -d /path/to/gerrit/site

What is the expected output? What do you see instead?
At the end of the instal, I see the following output:

Initialized /path/to/gerrit/site
Executing /path/to/gerrit/site/bin/gerrit.sh start
Starting Gerrit Code Review: OK
Waiting for server to start ... OK
Opening browser ...
Exception in thread "main" java.lang.Exception: Failed to start a browser to open the URL http://jenkins.diamond.ac.uk:8081/#/admin/projects/: Browser detection failed and system property h2.browser not set
        at org.h2.tools.Server.openBrowser(Server.java:647)
        at com.google.gerrit.pgm.init.Browser.open(Browser.java:89)
        at com.google.gerrit.pgm.Init$SiteRun.start(Init.java:249)
        at com.google.gerrit.pgm.Init.run(Init.java:93)
        at com.google.gerrit.pgm.util.AbstractProgram.main(AbstractProgram.java:67)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at com.google.gerrit.launcher.GerritLauncher.invokeProgram(GerritLauncher.java:168)
        at com.google.gerrit.launcher.GerritLauncher.mainImpl(GerritLauncher.java:92)
        at com.google.gerrit.launcher.GerritLauncher.main(GerritLauncher.java:50)
        at Main.main(Main.java:25)

Two problems here:
(1) The install was done by SSHing to a headless server (Linux). Gerrit should not assume that a browser is available on the system where the install is done - in fact, it's quite likely that there isn't one, since Gerrit would typically run on a server-type machine.
(2) If I did want to specify a path to a browser, I'm unlikely to realize system property h2.browser is what I need - since I'm not using the H2 database!

Probably the simplest fix is just to catch the exception and output a message asking the user to go the URL. In fact, in 2.5.2 Gerrit never tried to open a browser, it just told the user to.

May 6, 2013
#1 sop@google.com
(No comment was entered for this change.)
Labels: Blocking-2.6
May 13, 2013
#2 sop@google.com
https://gerrit-review.googlesource.com/45676
Status: ChangeUnderReview
May 14, 2013
#3 sop@google.com
(No comment was entered for this change.)
Status: Submitted
Labels: -Blocking-2.6 FixedIn-2.6