RJava/jri Setup

From CVRG Wiki

Jump to: navigation, search

Notes on setting up rJava/jri utilities to support a locally managed infrastructure

Introduction

The following are notes related to setting up the rJava/jri library, which is used by the Decision Tree Gadget.
These instructions are a variant on the instructions for RWebservices, developed by the BioConductor group.
If you are using the instance of the Decision Tree Gadget deployed at JHU, then this page will be unnecessary, as rJava/jri will installed and maintained at JHU by the CVRG team.
JRI is a Java/R Interface, which allows R programs to run inside Java applications.
JRI is needed because the Decision Tree analysis is executed in R, which is accessed via a Java web service. The user interface is a Google Web Toolkit (GWT) gadget, which calls this web service to perform the analysis. JRI is bundled with the complementary rJava to make the rJava/rni library. JRI is available as a standalone library, but the Decision Tree Gadget has not been tested with it.

Notes

  1. Install R script on the server, detailed instructions are here.
  2. Install the rJava/jri package in R as follows. (detailed instructions are here.)
    • sudo R CMD javareconf JAR=/opt/java/bin/jar JAVAH=/opt/java/bin/javah (or where ever your jar and javah directories are) from the command prompt.
    • install.packages(“rJava”) from within R console prompt.
  3. jri uses JNI (Java Native Interface) code.
    • JNI is non-Java code that must be compiled separately for the host machine's "Native" environment, Linux in the case of JHU's host.
    • The JNI code in included with the rJava/jri library file “libjri.so” for Linux (or “libjri.dll” for windows).
    • JNI doesn't use the environment variable PATH to find the libary, it uses LD_LIBRARY_PATH, so the location of "libjri.so" must be listed in LD_LIBRARY_PATH.
    • The small Java Archive "JRI.jar" references a C program which is in JNI code and should be put in the web service library directory (e.g. /opt/tomcat/webapps/axis2/WEB-INF/lib under Linux)
  4. The R-engine created by the jri library is a single instance and is not thread safe.
    • This can probably be handled by ActiveMQ, but has not been implemented in the Decision Tree Analysis web service yet.
    • jri has a 2nd contructor method which attaches to a running R-engine.
    • There is no obvious way to determine if an R-engine is running, so it sets a static flag after the 1st R-engine startup, and calls the 2nd constructor thereafter.
    • The R-engine works reliably and interacts with the web service properly, but has not been thoroughly tested with multiple simultaneous calls.
  5. CVRG has tested this with
    • Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_15-b04)
    • Apache Tomecat version 6.0.18
    • rJava/jri version 0.8-1 2009-10-30. More recent versions have not been tested. Up to version 0.8-3 the changes are in code speed and developer utilities so should be OK. Version 0.8-4(under development as of 4/16/2010) will change how NA results are returned, and will require refactoring of the Java code.
Personal tools
Project Infrastructures