Getting rjb, also known as "Ruby Java Bindings' to work in a Dreamhost account can be somewhat problematic. Fortunately, it is also fairly straightforward. You just have to install all the dependencies in the user directory.
In my case, I was setting up a Rails Application that used the iText Java library to fill in PDF documents for user download. Of course, the server environment was not using Sun Java and the Java headers were not present, so
gem install rjb failed. Joy.
The first course of action was to do a local install of Java.
Download
jdk-6u7-linux-x64.bin and
jre-6u7-linux-x64.bin from the Sun Java site. Then create an
~/opt directory and extract the JRE and JDK (you will need to
chmod u+x both files then call them from the command line). Move the resulting folders to
~/opt . I renamed the folders to
jdk and
jre for simplicity.
Now you ensure that user gems are enabled in cPanel. Then add the following 3 lines to
~/.bash_profileexport JAVA_HOME=/home/username/opt/jdkexport GEM_PATH=/home/username/ruby/gemsexport GEM_HOME=/home/username/ruby/gemsRun
source ~/.bash_profile to load the paths.
Now you can run
gem install rjb without any problems. You will likely have to re-install Rails and other gems because we will be telling our Rails app to load gems from the user directory. Just use the regular
gem install syntax.Add the following 2 lines to your config/environment.rb at the top
ENV['GEM_PATH']='/home/username/ruby/gems'ENV['JAVA_HOME']='/home/username/opt/jdk'That's pretty much it.
I will concede that these probably aren't the best instructions, but this is the real meat of the solution. If you keep getting "no such file to load" errors, you will need to extract the gems to the vendor/plugins directory.
cd RAILS_ROOT/vendor/plugins and
gem unpack gem_name for each problematic gem. I believe this is an issue with Passenger.
Please correct me if I am wrong about any of this, it was a very long day!