Install RDAVIDWebService

An R Package for retrieving data from DAVID into R objects using Web Services API.
  1. Upgrade Java
  2. Upgrade OpenSSL
  3. Update cacerts file
  4. rJava issues

Refer to this Bioconductor thread for some additional installation instructions from the RDavidWebService developer.


Java >= 1.8 and OpenSSL >= 1.0.2.d are required.

openssl version
java -version

Upgrade Java

Upgrade Java to the latest version with Homebrew.

brew cask install java

The latest JDK will be installed at /Library/Java/JavaVirtualMachines.

Upgrade OpenSSL

Compile the latest version from source. Refer to my openssl.sh build script as a reference, available in the koopa package.

Update cacerts file

cd ~/
echo -n | openssl s_client -connect david.ncifcrf.gov:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ncifcrf.cert

Check that the download was successful.

openssl x509 -in ncifcrf.cert -text

Find your cacerts file.

sudo find /Library/Java/JavaVirtualMachines -name cacerts

You should see something that matches /Library/Java/JavaVirtualMachines/jdk{VERSION}.jdk. Now with that virtual machine, we’re going to copy the cacerts file to the home directory, add the DAVID certificate, and copy back.

VERSION="1.8.0_131"
sudo cp /Library/Java/JavaVirtualMachines/jdk$VERSION.jdk/Contents/Home/jre/lib/security/cacerts .
sudo keytool -import -trustcacerts -keystore cacerts -storepass changeit -noprompt -alias david -file ncifcrf.cert
# The certificate should be added to the keystore.
# If successful, copy the modified `cacerts` file to the virtual machine.
sudo cp cacerts /Library/Java/JavaVirtualMachines/jdk$VERSION.jdk/Contents/Home/jre/lib/security/cacerts

Now update the Java configuration in R.

R CMD javareconf

Install RDAVIDWebService.

install.packages("rJava")
library(rJava)
.jinit()
.jcall("java/lang/System", "S", "getProperty", "java.runtime.version")

Note that the Java version here should match the JDK above. If this looks good, RDAVIDWebService should install correctly.

# try `http://` if `https://` URLs are not supported
source("https://bioconductor.org/biocLite.R")
biocLite("RDAVIDWebService")

rJava issues

If you get the following error message, there are two ways to fix the problem on macOS.

Error: package or namespace load failed for ‘RDAVIDWebService’:
 .onLoad failed in loadNamespace() for 'rJava', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '~/R/library/rJava/libs/rJava.so':
  dlopen(~/R/library/rJava/libs/rJava.so, 6): Library not loaded: @rpath/libjvm.dylib
  Referenced from: ~/R/library/rJava/libs/rJava.so
  Reason: image not found

First, you can symlink the libjvm.dylib file into /usr/local/lib.

sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib

Second, you can explicitly load the libjvm.dylib file in R before loading rJava.

dyn.load("/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server/libjvm.dylib")
library(rJava)

We prefer the first approach but it requires sudo permission elevation.