title: Running rJava within JRI in JBoss
body: <p>I'm running an R script in Jboss (a java application server) using JRI. Within the R script I have a call to a Java class. </p>
  
  <p>Therefore, this is what I have:</p>
  
  <p>Java program in JBoss --> invokes JRI and runs R script --> invokes Java program.</p>
  
  <p>When I attempt to run the following script in JRI: </p>
  
  <pre><code>s &lt;- .jnew("java/lang/String", "Hello World")
  print(s)
  </code></pre>
  
  <p>The program runs, however throws the following exception:</p>
  
  <blockquote>
    <p>12:18:16,786 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)
    java.lang.NoClassDefFoundError: RJavaClassLoader</p>
    
    <p>12:18:16,786 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at
    org.rosuda.JRI.Rengine.rniEval(Native Method)</p>
    
    <p>12:18:16,786 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at
    org.rosuda.REngine.JRI.JRIEngine.eval(JRIEngine.java:281)</p>
    
    <p>12:18:16,802 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at
    org.rosuda.REngine.REngine.parseAndEval(REngine.java:102)</p>
    
    <p>12:18:16,803 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at
    org.rosuda.REngine.REngine.parseAndEval(REngine.java:108)</p>
  </blockquote>
  
  <p>The first time I run an rJava statement, I get the exception. From then on, it <em>almost</em> works fine, the main problem is that the environment is not stable, as I see many exceptions from time to time.</p>
  
  <p>I know that is possible to run rJava from within JRI, but is it possible in an application server like Jboss instead of a plain Java object?</p>