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:
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
net.snowflake.client.core.SFTrustManager
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.
I'm at a loss here, too. Does changing the user back to rstudio-connect cause the app to start failing again? Do you know what the permissions on the file are?
You could also try running R as the rstudio-connect user (manually, outside of Connect) and see whether accessing rJava / java / etc. works. Usually this requires something like su -s /bin/bash rstudio-connect to assume the rstudio-connect user.
The other possibility is that R needs to be configured for non-privileged users to use Java. rJava is one of the few packages that we often end up recommending that users install as an "external package," because it does sometimes require some more system-level configuration than Connect knows how to do on installation (sudo /path/to/R CMD javareconf and the like).
Please do let us know if you try some of these ideas and whether they turn out to be helpful at all! Fixing Java problems always feels a lot like flailing
Changing the user back to rstudio-connect in the app Access panel results in the same failure. I threw a file.info call into the app logs, which returned about what I expected (see below). It's worth noting that in this case, I am referencing the driver file from inside a custom package called CARS via system.file, but I get the exact same behavior if I add the driver file directly to the Connect content bundle.
Running the code manually as the rstudio-connect user as you described results in the same failure, even after running R CMD javareconf on the associated R binary.
Could it possibly have something to do with the rstudio-connect user not having a home folder?