I'm trying to set up R and Tomcat on RHEL6 (6.4)
我正在尝试在RHEL6(6.4)上设置R和Tomcat
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.
我已经安装了R并且可以运行它。我已经安装了Tomcat 7并且可以托管文件文件。我已将应用程序打包为WAR文件,并使用tomcat进行部署。应用程序在所有方面运行良好,直到它使用任何R组件。
This is where it crashes out with the following error as seen in catalina.out:
这是崩溃的地方,出现以下错误,如catalina.out中所示:
Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in java.li
brary.path.
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 link
s
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)
I do have rJava installed under R: install.packages("rJava") It installed fine and I have rJava inside the R's library folder.
我确实在R下安装了rJava:install.packages(“rJava”)它安装得很好,我在R的库文件夹中有rJava。
I have defined the following in /etc/profile:
我在/ etc / profile中定义了以下内容:
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
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 as set above via "echo $JAVA_HOME
", "echo $R_HOME
", "echo $LD_LIBRARY_PATH
", "echo $PATH
"
根据我的理解,应该为服务器上的所有用户全局设置JAVA_HOME,R_HOME,PATH和LD_LIBRARY_PATH。我知道Tomcat在root下运行,我可以确认root能够通过“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.
所以我不确定为什么它抱怨它无法打开那些.so文件。
Also, when it crashes out, it shuts down Tomcat.
此外,当它崩溃时,它会关闭Tomcat。
Thanks!
谢谢!
2 个解决方案
#1
2
I had the same issue when I was using R libraries with tomcat. It couldn't find R_HOME.
当我使用带有tomcat的R库时,我遇到了同样的问题。它找不到R_HOME。
The solution is to update a file that sets the path for tomcat because tomcat sets its own variables. The file is "yourPathToTomcat/tomcat/bin/setclasspath.sh", open it and add at the end "export R_HOME=yourPathToR" (just like what you added in your linux environments e.g: export R_HOME=/usr/lib/R). Then you can run your app and it will work. Hope It might help someone. :D
解决方案是更新设置tomcat路径的文件,因为tomcat设置自己的变量。该文件是“yourPathToTomcat / tomcat / bin / setclasspath.sh”,打开它并在末尾添加“export R_HOME = yourPathToR”(就像你在linux环境中添加的那样,例如:export R_HOME = / usr / lib / R) 。然后你可以运行你的应用程序,它会工作。希望它可以帮助某人。 :d
#2
1
To use R from Java you will need to install JRI. Fortunately, JRI is now a part of rJava and is installed with it.
要从Java使用R,您需要安装JRI。幸运的是,JRI现在是rJava的一部分并随之安装。
JRI will require its own native shared library which is already installed with rJava. To locate JRI installed with rJava, use
JRI将需要自己的本机共享库,该库已经与rJava一起安装。要找到使用rJava安装的JRI,请使用
system.file("jri",package="rJava")
from inside of R [command-line]. Above command will give you a path. You will be able to find
从R [命令行]里面。上面的命令会给你一个路径。你将能够找到
libjri.so
which is the shared library JRI is looking for. You can specify this path retrieved above through JAVA_OPTS as
这是JRI正在寻找的共享库。您可以通过JAVA_OPTS将上面检索到的路径指定为
-Djava.library.path=${path-retrieved-from-R}
which will be passed on to the JVM settings on initialization of Tomcat.
这将在Tomcat初始化时传递给JVM设置。
If you are using multiple libraries then please group the library path java option accordingly.
如果您使用多个库,请相应地对库路径java选项进行分组。
#1
2
I had the same issue when I was using R libraries with tomcat. It couldn't find R_HOME.
当我使用带有tomcat的R库时,我遇到了同样的问题。它找不到R_HOME。
The solution is to update a file that sets the path for tomcat because tomcat sets its own variables. The file is "yourPathToTomcat/tomcat/bin/setclasspath.sh", open it and add at the end "export R_HOME=yourPathToR" (just like what you added in your linux environments e.g: export R_HOME=/usr/lib/R). Then you can run your app and it will work. Hope It might help someone. :D
解决方案是更新设置tomcat路径的文件,因为tomcat设置自己的变量。该文件是“yourPathToTomcat / tomcat / bin / setclasspath.sh”,打开它并在末尾添加“export R_HOME = yourPathToR”(就像你在linux环境中添加的那样,例如:export R_HOME = / usr / lib / R) 。然后你可以运行你的应用程序,它会工作。希望它可以帮助某人。 :d
#2
1
To use R from Java you will need to install JRI. Fortunately, JRI is now a part of rJava and is installed with it.
要从Java使用R,您需要安装JRI。幸运的是,JRI现在是rJava的一部分并随之安装。
JRI will require its own native shared library which is already installed with rJava. To locate JRI installed with rJava, use
JRI将需要自己的本机共享库,该库已经与rJava一起安装。要找到使用rJava安装的JRI,请使用
system.file("jri",package="rJava")
from inside of R [command-line]. Above command will give you a path. You will be able to find
从R [命令行]里面。上面的命令会给你一个路径。你将能够找到
libjri.so
which is the shared library JRI is looking for. You can specify this path retrieved above through JAVA_OPTS as
这是JRI正在寻找的共享库。您可以通过JAVA_OPTS将上面检索到的路径指定为
-Djava.library.path=${path-retrieved-from-R}
which will be passed on to the JVM settings on initialization of Tomcat.
这将在Tomcat初始化时传递给JVM设置。
If you are using multiple libraries then please group the library path java option accordingly.
如果您使用多个库,请相应地对库路径java选项进行分组。