On Mar 24, 2013, at 3:56 AM, Patrick Hong wrote:

> I'm trying to set up R and Tomcat on RHEL6 (6.4)
> 
> I have installed R and can run it. I have installed Tomcat 7 and can host
> files file. I have packaged an application as a WAR file and deployed it
> using tomcat. The application runs fine in all aspects until it uses any R
> component.
> 
> This is where it crashes out with the following error as seen in
> catalina.out:
> 
> <code>
> Cannot find JRI native library!
> Please make sure that the JRI native library is in a directory listed in
> java.library.path.

I prefer setting "java.library.path" to setting "LD_LIBRARY_PATH", as the first 
is system independent.  They should both work though.

> 
> java.lang.UnsatisfiedLinkError:
> /usr/local/lib64/R-2.15.3/library/rJava/jri/libj
> ri.so: libR.so: cannot open shared object file: Too many levels of symbolic
> links

This error "Too many levels of symbolic links" usually happens when there is a 
problem with your symbolic links.  For example, you have a link to a link which 
links to another link, etc…  or when you have circular links.  

A couple things you can do to debug further.

1.) Manually follow the symbolic links for "libR.so" (what it appears to be 
trying to load) using "ls".  
2.) Use the "ldd" command ex:  "ldd libR.so".  Make sure ldd is able to locate 
all the required libraries.

> at java.lang.ClassLoader$NativeLibrary.load(Native Method)
> at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
> at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1675)
> at java.lang.Runtime.loadLibrary0(Runtime.java:840)
> at java.lang.System.loadLibrary(System.java:1047)
> at org.rosuda.JRI.Rengine.<clinit>(Rengine.java:19)
> </code>
> 
> I do have rJava installed under R: install.packages("rJava") It installed
> fine and I have rJava inside the R's library folder.
> 
> I have defined the following in /etc/profile:
> 
> <code>
> export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre
> export R_HOME=/usr/local/lib64/R-2.15.3
> PATH=$PATH:$HOME/bin:$JAVA_HOME/bin:$R_HOME/bin
> export PATH
> export 
> LD_LIBRARY_PATH=$R_HOME/lib/libR.so,$JAVA_HOME/lib/amd64/server/libjvm.so

This looks wrong.  

1.) Items specified by LD_LIBRARY_PATH should point to directories not shared 
libraries.  Try using "$R_HOME/lib".

"In Linux, the environment variable LD_LIBRARY_PATH is a colon-separated set of 
directories where libraries should be searched for first, before the standard 
set of directories;"

http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

2.) Why are you including the path to "libjvm.so"?  This is not something you 
would normally do.


> </code>
> 
> To my understanding, that should set JAVA_HOME, R_HOME, PATH, and
> LD_LIBRARY_PATH globally for all users on the server. I know Tomcat runs
> under root and I can confirm that root was able to see all the above paths

Running Tomcat as root is a *really* bad idea.  You should create a dedicated 
user with minimal permissions to run Tomcat.  This will limit the scope of what 
an attacker could accomplish should he or she be able to compromise your system.

Dan


> as set above via "echo $JAVA_HOME", "echo $R_HOME", "echo $LD_LIBRARY_PATH",
> "echo $PATH"
> 
> So I'm not sure why it's complaining that it can't open those .so files.
> 
> Also, when it crashes out, it shuts down Tomcat.
> 
> Thanks!
> 
> Patrick
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to