Unable to make JDBC connection when running as rstudio-connect user

September 19, 2019 @jeff.keller Jeff Keller

@jeff.keller wrote:

This is a weird one...

I have a shiny app that calls out to a database using a JDBC connection with a .jar file that is supplied with the app bundle. The code runs fine on other machines and looks like:

driver <- RJDBC::JDBC(driverClass = "net.snowflake.client.jdbc.SnowflakeDriver", 
        classPath = "localfile.jar")
conn <- RJDBC::dbConnect(driver, url, username, password)
RJDBC::dbGetQuery(conn, statement = sql)

However on Connect, this code throws an error when run as the default rstudio-connect user:

Error in .jcall(drv@jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1],  : 
  java.lang.NoClassDefFoundError: Could not initialize class 

On a hunch, I added a super user on the RStudio Connect host machine to the rstudio-connect group and ran the app under that user and it works!

I'm at a loss here... what possible permissions could the default rstudio-connect user be lacking such that this file (or something Java related) is not accessible? I feel like there are so many possibilities I'm hoping someone knowledgeable could help narrow it down.

Posts: 4

Participants: 2

Read full topic

Previous Article
Docker, NGINX, Shiny-Server, SSL - Page rendering issue
Docker, NGINX, Shiny-Server, SSL - Page rendering issue

@Landon wrote: Hi everyone, I'm currently working in a docker environment levera...

Next Article
Install package error for Shiny Server
Install package error for Shiny Server

@serbaysimsir wrote: I want take help/feedback that ı am facing with. I installe...