0
votes

I have a .Rmd along with a .sql file that is read by the .Rmd file that I’m trying to deploy in ShinyProxy. I am able to run this from within RStudio on my Mac.

The application loads, I can see it in ShinyProxy, but when I click on the application, it launches, then says please wait, then the error java.lang.StackOverflowError. I tried increasing the stack size with the JAVA_OPTS in the Dockerfile.

I do see this in shinyproxy.log:

java.lang.reflect.InvocationTargetException: null at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_332] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_332] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_332] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_332] . . . . Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:673) ~[na:1.8.0_332] at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313) ~[na:1.8.0_332] at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:350) ~[na:1.8.0_332] at javax.naming.InitialContext.lookup(InitialContext.java:417) ~[na:1.8.0_332] ... 140 common frames omitted

Dockerfile:

FROM openanalytics/r-base

MAINTAINER John Reber "[email protected]"

ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
RUN export JAVA_HOME

ENV JAVA_OPTS "-Xms4G -Xmx8G -Xss2G"
RUN export JAVA_OPTS

# Install Java for rJava
RUN apt-get update &&  \
    apt-get install -y default-jdk && \
    apt-get install -y default-jre && \
    apt-get install -y ca-certificates-java && \
    rm -rf /var/lib/apt/lists/*

RUN ["java", "-version"]

CMD javareconf

RUN apt-get update && apt-get install -y \
    libcurl4-openssl-dev \
#    libcurl4-gnutls-dev \
    libssl-dev \
    libxml2-dev && \
    rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y \
    libharfbuzz0b && \
    rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y \
    sudo \
    pandoc \
    pandoc-citeproc \
    libcairo2-dev \
    libxt-dev \
    libssh2-1-dev && \
    rm -rf /var/lib/apt/lists/*

WORKDIR    /opt/oracle
RUN        apt-get update && apt-get install -y libaio1 wget unzip \
            && wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip \
            && unzip instantclient-basiclite-linuxx64.zip \
            && rm -f instantclient-basiclite-linuxx64.zip \
            && cd /opt/oracle/instantclient* \
            && rm -f *jdbc* *occi* *mysql* *README *jar uidrvci genezi adrci \
            && echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf \
            && ldconfig

WORKDIR /

RUN apt-get update && apt-get install -y \
    libmysql++-dev \
    unixodbc-dev \
    libpq-dev && \
    rm -rf /var/lib/apt/lists/*

#RUN apt-get update && apt-get install -y \
#    libxml2 \
#    libssl1.1 && \
#    rm -rf /var/lib/apt/lists/*

CMD javareconf

RUN ["java", "-version"]

# install needed R packages
#RUN    R -e "install.packages(c('flexdashboard', 'knitr', 'plotly', 'httpuv', 'shiny', 'rJava', 'RJDBC', 'dplyr', 'readr', 'DT', 'lubridate', 'rmarkdown'), dependencies = TRUE, repo='http://cran.r-project.org')"
RUN    R -e "install.packages(c('shiny'), dependencies = TRUE, repo='https://cloud.r-project.org')"
RUN    R -e "install.packages(c('flexdashboard',  'dplyr', 'rJava',  'RJDBC', 'readr', 'DT', 'lubridate', 'rmarkdown'), dependencies = TRUE, repo='https://cloud.r-project.org')"
#  'sysfonts','gifski', 'Cairo', 'tidyverse',


# make directory and copy Rmarkdown flexdashboard file in it
RUN mkdir -p /prmc
COPY prmc/PRMC.Rmd /prmc/PRMC.Rmd
#COPY prmc/PRMC_Local.Rmd /prmc/PRMC_Local.Rmd
COPY prmc/prmc.sql /prmc/prmc.sql
#COPY prmc/PRMC_ACCRUAL.csv /prmc/PRMC_ACCRUAL.csv
COPY prmc/ojdbc11.jar /prmc/ojdbc11.jar

# Copy Rprofile.site to the image
COPY Rprofile.site /usr/local/lib/R/etc/


# make all app files readable (solves issue when dev in Windows, but building in Ubuntu)
RUN chmod -R 755 /prmc

# expose port on Docker container
EXPOSE 3838

# run flexdashboard as localhost and on exposed port in Docker container
CMD ["R", "-e", "rmarkdown::run('/prmc/PRMC.Rmd', shiny_args = list(port = 3838, host = '0.0.0.0'))"]

application.xml:

proxy:
#  title: Open Analytics Shiny Proxy
  title: SKCC Open Analytics ShinyProxy
#  logo-url: https://www.openanalytics.eu/shinyproxy/logo.png
  logo-url: https://ewebapp01pa.jefferson.edu/includes/images/logo-2014.jpg
  landing-page: /
  heartbeat-rate: 10000
  heartbeat-timeout: 60000
  port: 8081
#  authentication: keycloak
  authentication: simple
  admin-groups: admin
  useForwardHeaders: true
# Example: 'simple' authentication configuration
  users:
    - name: jack
      password: XXXXXXXX
      groups: scientists, admin
    - name: jeff
      password: XXXXXXXXX
      groups: mathematicians
#   keycloak authentication
  keycloak:
    auth-server-url: https://kc.kcc.tju.edu/auth
    realm: shinyproxy
    public-client: true
    resource: shinyproxy
    credentials-secret: s2NwbneBKh10wG0fHjZjevGnLlNTt44h
    use-resource-role-mappings: false
#   Docker configuration
  docker:
    url: http://localhost:2375
    port-range-start: 20000
  specs:
    - id: 01_hello
      display-name: Hello Application
      description: Application which demonstrates the basics of a Shiny app
      container-cmd: ["R", "-e", "shinyproxy::run_01_hello()"]
      container-image: openanalytics/shinyproxy-demo
      access-groups: [scientists, mathematicians, analyze, admin]
#    - id: 06_tabsets
#      display-name: 06_tabsets
#      description: Application 06_tabsets demonstration
#      container-cmd: ["R", "-e", "shinyproxy::run_06_tabsets()"]
#      container-image: openanalytics/shinyproxy-demo
#      access-groups: []
##    - id: euler
#      display-name: Euler's number
#      container-cmd: [ "R", "-e", "shiny::runApp('/root/euler')" ]
#      container-image: openanalytics/shinyproxy-template
#      access-groups: scientists
    - id: prmc
      display-name: PRMC Dashboard
      description: (Protocol Review Monitoring Committee Dashboard)
      docker-cmd: ["R", "-e rmarkdown::run('/prmc/PRMC.Rmd')"]
      container-image: prmc_dashboard3
      access-groups: [scientists, mathematicians, analyze, admin]
logging:
  file:
    name: shinyproxy.log
  level:
    root: DEBUG