s-u / rJava

R to Java interface
https://RForge.net/rJava
233 stars 77 forks source link

Error during initialization of VM: java/lang/NoClassDefFoundError: java/lang/Object #263

Closed tedmoorman closed 2 years ago

tedmoorman commented 3 years ago

This issue originally arose from trying to specify a JDBC driver in the RJDBC package. I moved back a step to rJava to see if I could get similar errors. It's similar to #62, but the original poster didn't continue to provide feedback.

Here is the error:

> .jinit()      
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object

Here is some information about my system:

> sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server 7.9 (Maipo)

Matrix products: default
BLAS: /opt/R/R-3.5.3/lib64/R/lib/libRblas.so
LAPACK: /opt/R/R-3.5.3/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.5.3 renv_0.13.2 

Here is information about the Java version and settings:

$ /opt/R/R-3.5.3/bin/R CMD javareconf -n
*** JAVA_HOME is not a valid path, ignoring
Java interpreter : /usr/bin/java
Java version     : 1.8.0_265
Java home path   : /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.el7_9.x86_64/jre
Java compiler    : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar

trying to compile and link a JNI program 
detected JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
gcc -std=gnu99 -I"/opt/R/R-3.5.3/lib64/R/include" -DNDEBUG -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.el7_9.x86_64/jre/../include -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.el7_9.x86_64/jre/../include/linux  -I/usr/local/include   -fpic  -g -O2  -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/opt/R/R-3.5.3/lib64/R/lib -L/usr/local/lib64 -o conftest.so conftest.o -L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.el7_9.x86_64/jre/lib/amd64/server -ljvm -L/opt/R/R-3.5.3/lib64/R/lib -lR

JAVA_HOME        : /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.el7_9.x86_64/jre
Java library path: $(JAVA_HOME)/lib/amd64/server
JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm

Here is the default JAVA_HOME set by my admins (which I can change in my .bash_profile):

$ echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/lib/amd64

Here is the default CLASSPATH set by my admins (which I can change in my .bash_profile):

$ echo $CLASSPATH
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/lib

Here are additional environmental settings from Sys.getenv()

> Sys.getenv()
CLASSPATH               /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/lib
COLUMNS                 204
CVS_RSH                 ssh
EDITOR                  vi
GDAL_DATA               /usr/share/epsg_csv
HARDWARE_PLATFORM       x86_64
HISTCONTROL             ignoredups
HISTSIZE                1000
HOME                    /home/uid
HOSTNAME                xxx.xxx.xxx.xxx.xxx
IQDIR16                 /opt/app/SybaseIQ/IQ-16_1
JAVA_HOME               /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/lib/amd64
KRB5CCNAME              KEYRING:persistent:xxxxxx
LANG                    en_US.UTF-8
LD_LIBRARY_PATH         /opt/glpk-4.65/lib:/usr/local/lib:usr/local/lib64:/opt/app/SybaseIQ/IQ-16_1/lib64
LESSOPEN                ||/usr/bin/lesspipe.sh %s
LINES                   55
LN_S                    ln -s
LOGNAME                 8b3sb
LS_COLORS               rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
MAIL                    /var/spool/mail/uid
MAKE                    make
ODBCINI                 /opt/app/SybaseODBC/odbc.ini
PAGER                   /bin/less
PATH                    /opt/R/R-3.5.3/bin:/opt/Python-3.7.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/app/SybaseIQ/IQ-16_1/bin64
PWD                     /home/uid
QT_GRAPHICSSYSTEM_CHECKED
                        1
R_ARCH                  
R_BROWSER               /bin/xdg-open
R_BZIPCMD               /bin/bzip2
R_DOC_DIR               /opt/R/R-3.5.3/lib64/R/doc
R_GZIPCMD               /bin/gzip
R_HOME                  /opt/R/R-3.5.3/lib64/R
R_INCLUDE_DIR           /opt/R/R-3.5.3/lib64/R/include
R_LIBS_SITE             
R_LIBS_USER             /projects/CI_Analysts/R/x86_64-pc-linux-gnu-library/3.5
R_PAPERSIZE             a4
R_PDFVIEWER             /bin/xdg-open
R_PLATFORM              x86_64-pc-linux-gnu
R_PRINTCMD              lpr
R_RD4PDF                times,hyper
R_REPOSITORIES          repos
R_SESSION_TMPDIR        /tmp/RtmpqHbRcH
R_SHARE_DIR             /opt/R/R-3.5.3/lib64/R/share
R_SYSTEM_ABI            linux,gcc,gxx,gfortran,?
R_TEXI2DVICMD           texi2dvi
R_UNZIPCMD              /bin/unzip
R_ZIPCMD                /bin/zip
SAP_JRE8                /opt/app/SybaseIQ/shared/SAPJRE-8_1_046_64BIT
SAP_JRE8_64             /opt/app/SybaseIQ/shared/SAPJRE-8_1_046_64BIT
SED                     /bin/sed
SELINUX_ROLE_REQUESTED

SELINUX_USE_CURRENT_RANGE
                        1
SHELL                   /bin/bash
SHLVL                   2
SSH_ASKPASS             /usr/libexec/openssh/gnome-ssh-askpass
SSH_CLIENT              xx.xxx.xx.xx xxxxx xx
SSH_CONNECTION          xx.xxx.xx.xx xxxxx xx.xxx.xx.xx xx
SSH_TTY                 /dev/pts/127
SYBASE                  /opt/app/SybaseIQ
SYBROOT                 /opt/app/SybaseIQ
TAR                     /bin/gtar
TERM                    xterm
USER                    uid
XDG_RUNTIME_DIR         /run/user/xxxxxx
XDG_SESSION_ID         xxxxxx

There are multiple Java versions on the server I'm using:

$ alternatives --display java | grep priority | grep java-
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.el7_9.x86_64/jre/bin/java - family java-1.8.0-openjdk.x86_64 priority 1800265
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64-debug/jre/bin/java - family java-1.8.0-openjdk.x86_64 priority 1800241
/usr/lib/jvm/java-1.8.0-ibm-1.8.0.6.10-1jpp.1.el7.x86_64/jre/bin/java - priority 180610

Is there anything else I can provide?

Any insight is appreciated.

s-u commented 2 years ago

Essentially your Java setting are invalid. You have to re-configure R with correct settings that match your JDK - typically best way is to unset JAVA_HOME, make sure the correct java and javac are on your PATH and then run R CMD javareconf. If you don't have admin permissions to fix the broken R setup then you will have to use javareconf -n to compile and then set the correct settings (JAVA_HOME and R_JAVA_LD_LIBRARY_PATH) in your environment before you start R since R will prefer your environment settings over the site settings if set. Ideally, you should get your admins to fix the broken system since they were responsible for breaking it.

Note that you can compile against one JDK and then use another - they are all binary compatible (however, class files are only backwards compatible so you can't use newer class files with older JDK but you can vice versa).

tedmoorman commented 2 years ago

I really appreciate the response, Simon. I'm passing this along to the admins to get fixed.