Score:0

R Apache Error: package 'rJava' could not be loaded

pw flag

I sucessfully installed RApache on my Debian 11 server. The following R script runs flawlessly when being executed via URL/Apache:

y = rnorm(100)
print(y) 

Sadly, another script with rJava/RJDBC embedded causes an internal server error:

Sys.setenv(LD_LIBRARY_PATH = "/usr/lib/jvm/default-java/bin/java")
options(java.parameters = c("-Djdk.tls.client.protocols=TLSv1.2"))

library(RJDBC)

# Verbindungsinformationen
server <- "172.20.10.84\\SESQL"
database <- "SEMESS"
username <- " "
password <- " "

# JDBC-Treiber laden 
jdbc_driver <- "/etc/mssql-jdbc-12.2.0.jre11.jar"
drv <- JDBC(driverClass = "com.microsoft.sqlserver.jdbc.SQLServerDriver", classPath = jdbc_driver)

# Verbindung aufbauen
conn <- dbConnect(drv, sprintf("jdbc:sqlserver://%s;databaseName=%s;encrypt=true;trustServerCertificate=true", server, database), username, password)

dbDisconnect(conn)

The script runs smoothly when being excuted with Rscript test.R.

When making an sudo tail -f /var/log/apache2/error.log it shows:

libjvm.so: cannot open shared object file: No such file or directory Error: package 'rJava' could not be loaded

Any hints for me for fixing this problem? I already tried to add SetEnv LD_LIBRARY_PATH with the Java Library Path to my Apache 000-default.conf.

Any help is highly appreciated.

Score:0
pw flag

it turns out that adding

dyn.load("/usr/lib/jvm/java-11-openjdk-amd64/lib/server/libjvm.so")

in the R script on the very top solved the problem.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.