Installing Gerrit on Glassfish

Yey, I’m finally back!! This time I’ll share with you how to get Gerrit deployed on Glassfish application server and MySQL.

The pre-requisites are:

  • MySQL up and running and experience creating databases and defining privileges;
  • Glassfish up and running and the experience creating JDBC Datasources and deploying applications, including managing library dependencies for JDBC and others – in this case, you’ll need to provide MySQL JDBC driver and Bouncy Castle crypto API libraries to Gerrit.

If you’re ready, follow me now:

    1. Create a database for Gerrit
              mysql -u root -p
      
              CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';
              CREATE DATABASE reviewdb;
              ALTER DATABASE reviewdb charset=latin1;
              GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
              FLUSH PRIVILEGES;
    2. Download the latest version of Gerrit. By the time of this writing, it was 2.2.1.
    3. Initialize Gerrit in standalone mode (for now). Don’t forget to provide the correct MySQL configuration:
      java -jar gerrit-2.2.1.war init -d gerrit

If all goes well, you should have a new directory named gerrit with everything you need to get Gerrit running. Also, the standalone server (Jetty) should be up. Stop it:

    gerrit/bin/gerrit.sh stop

Now, let’s configure Glassfish datasource. Please, pay attention as this was where I got into problems..

  1. Create a JDBC Connection Pool with type javax.sql.DataSource and MySQL as datasource classname.
  2. Enable Ping mode.
  3. Define DatabaseName, User, Password, Server depending on what information you’ve provided while initializing Gerrit.
  4. Finally and most importantly, define both URL and Url properties to something like jdbc:mysql://localhost:3306/reviewdb?autoReconnect=true
  5. The parts in italic bold are the ones to change according to your own configuration.

Try to ping your datasource to check if it’s OK. It is? Great! Now, let’s proceed with the deployment of Gerrit:

    asadmin deploy --contextroot codereview --name gerrit-2.2.1 gerrit-2.2.1.war

It should be working now! Point your browser to http://your_host/codereview, et voilá🙂

Gerrit working on Glassfish application server and on top of MySQL

Gerrit working on Glassfish application server and on top of MySQL

2 thoughts on “Installing Gerrit on Glassfish

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s