Question

We recently were able to get a small redhat server to experiment with shiny-server. Our IT department got shiny-server running and installed the Oracle client but I can't get ROracle to work in shiny-server. They (IT) have decided that it is an application issue and are starting to give up...

Initially ROracle didn't work on the server at all but we got it working from my user account by setting the LD_LIBRARY_PATH in my .bashrc file. With that done I can log into the server, and query the database from R. I can even use runApp() to run my shiny app from R.

When I try to access that same app through shiny-server I get the following error:

Listening on port 40679
Loading required package: DBI
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/usr/lib64/R/library/ROracle/libs/ROracle.so':
  libclntsh.so.11.1: cannot open shared object file: No such file or directory
Error : package or namespace load failed for 'ROracle'
Error : package or namespace load failed for 'ROracle'

which is the same error I was getting on my account before I set the LD_LIBRARY_PATH variable. The server is running as user shiny but apparently won't run any startup scripts so what fixed it for my user won't fix it for the shiny user. This is all very far outside my area of knowledge and as I said, our IT department says they are out of ideas.

I don't have sudo access to the server so the things I can try are limited. I tried setting the LD_LIBRARY_PATH from my server.R script before loading ROracle with Sys.setenv() and by using system() but those didn't work. Our DBA that has been trying to help me tried setting the LD_LIBRARY_PATH in /etc/init/shiny-server.conf but that doesn't seem to work either.

I am really hoping that someone here has some ideas.

Thanks

Was it helpful?

Solution

After a couple of frustrating days I found the solution. You need to set the LD_LIBRARY_PATH variable in the upstart script located at /etc/init/shiny-server.conf, but per the upstart documentation, you need to define it with the env keyword. So adding:

env LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib:$LD_LIBRARY_PATH

to beginning of the shiny-server.conf script seems to have fixed the problem.

OTHER TIPS

Here's my blog post (about a year old) with a detailed description on how to get R Studio Server going with Oracle. LD_LIBRARY_PATH, OCI Lib and all the stuff is provided. Maybe this helps someone else: http://learnfrominfo.tumblr.com/post/38382388429/connect-r-studio-server-to-an-oracle-database-with

I had the same problem with PHP and Apache.

Please refer to the Setting the Oracle Environment in the PHP documentation.

Also, see comment - which syntax did you use in /etc/init/shiny-server.conf?

SERVER.R
library
library(RMySQL)
library(caTools)
library(rpart)
library(RJDBC)
shinyServer(

  function(input ,output)
  {
    dvr =JDBC("oracle.jdbc.OracleDriver",classPath="D:/ojdbc6.jar")

url = ""
user = ""
password = ""
jd =dbConnect(dvr,url, user, password)
a1 <- eventReactive(input$predict,
                    {
                      a<-input$ref
                      table2<-data.frame(dbGetQuery(jd,paste0("
                                select colnames from Tablename where REFNO=",a,"  and ROWNUM<15
                                                    ")))
                      print(table2)
                      print(bs<-table2)

                    }

)




output$dis<-renderTable({
    a1()

    })

 }
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top