Installing redmine 1.0.1 on jruby and glassfish

I just completed the installation of redmine using jruby & glassfish on a redhat server. It took me a couple of hours to get it working correctly.

General Informations

  • For the installation, when you run any ruby programs you better do it with jruby -S <program> to avoid conflicts between ruby and jruby
  • if you download a redmine release, rails and gems are already included in the vendor’s folder so you don’t need to install them
  • If you have already installed redmine on jruby with some other help and you are having problems (like missing gems or some weird mysql exception), look below the database.yml file and the warble.rb changes, that might fix your problems!

I used the following versions of the different components :

  1. redmine 1.0.1
  2. jruby 1.5.2
  3. mysql 5.0.77
  4. glassfish 3.0.1 (build 22)
  5. mysql-connector-java-5.1.12

But hopefully any other combination should work as well…

Prerequisites

  • download and untar  all the above software if it’s not done yet, install mysql & glassfish.
  • add jruby to your PATH variable
  • make sure you have access to  mysql with an admin account (root) to create new databases, mysqld (daemon) needs to be running.
  • make sure your glassfish installation is working (you can try to login as admin on http://<host>:4848)
  • Also in glassfish, configure the Ruby container to point to your jruby installation path

Installation steps

Download gems

Download and install the gems that redmine needs (warble is used to pack redmine rails application as a war file to be deployed on a JEE container, see below):

jruby -S gem install jruby-openssl activerecord-jdbcmysql-adapter warbler

Database setup

  • Log on as root and create the redmine database
  • create database redmine character set utf8;
  • create the redmine user account ( change pwd to your own password)
  • create user 'redmine'@'localhost' identified by 'pwd';
  • grant privileges
  • grant all privileges on redmine.* to 'redmine'@'localhost';

mysql-connector configuration

  • copy the mysql-connector.jar file to your glassfish installation lib folder
  • in the glassfish bin folder use the asadmin tool to create a connection jdbc pool:
asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource \
--restype javax.sql.DataSource --property "User=redmine:Password=pwd:URL=jdbc\:mysql\://localhost\:3306/redmine" \
jdbc/RedminePool

and

asadmin create-jdbc-resource --connectionpoolid jdbc/RedminePool jdbc/Redmine

Those steps can also be done in the web administration console of glassfish.

redmine configuration

  • in the redmine config/environments folder copy production.rb to production_setup.rb
  • in the redmine config/ folder copy database.yml.example to database.yml
  • modify the config/database.yml file and make sure you have the following with your password:
# MySQL (default setup).

production:
adapter: jdbc
jndi: jdbc/Redmine
driver: com.mysql.jdbc.Driver

production_setup:
adapter: jdbcmysql
database: redmine
host: localhost
username: redmine
password: pwd
encoding: utf8

Create schema and populate default data

In the redmine folder , start the following commands to create the database schema and enter the default data (roles, …) :

jruby -S rake db:migrate RAILS_ENV=production

and

jruby -S rake redmine:load_default_data RAILS_ENV=production

Prepare for deployment

Now we need to prepare the war file that will be deployed to the JEE container. For this step, we use warble.

  • first, we need a warble config file. So, in the redmine folder, issue the command
  • jruby -S warble config

    (that generates config/warble.rb file)

  • Open config/warble.rb in your preferred editor and modify the line config.dirs so that it contains :
config.dirs = %w(app config lib log vendor tmp extra files lang)
  • in the same file add the line
    config.gems["rack"] = "1.0.1"

    and make sure the line

    config.gems += ["activerecord-jdbcmysql-adapter", "jruby-openssl"]

    is not commented out.

  • issue the command
     jruby -S warble.
  • That should create a war file that you can deploy to your glassfish server.
  • An easy way to deploy it to glassfish:
     cp <redmine.war> <glassfishinstallation>/domains/<domainname>/autodeploy/
  • and then stop/restart glassfish:
  •  <glassfishinstallation/bin/asadmin stop-domain <domainname>
    <glassfishinstallation/bin/asadmin start-domain <domainname>

Now, redmine should be working!


Start enjoying redmine

Log on to redmin as administrator with admin/admin.

Useful links

redmine installation

redmine on jruby

jdbc connection poll, jndi, rails