Skip to content

Issue when using RJAVA inside reactive expression in a Shiny App #357

@emilianomm

Description

@emilianomm

Hi! I've been recently trying out rix and encountered the following issue

Context

I'm working in a shiny app docker image and decided to give a try to rix. Dependency management worked really well with minimum setup time, even for my project that has a considerable amount of dependencies.

I'm using RJDBC to query against a remote dbms to render a few tables on the app. All worked fine, except calls to RJDBC::dbGetQuery when called inside a reactive expression.

Examples

1. Would do fine

writeFile <- observe({
  # Consider conx properly defined in an external file invoked by source()
  query <- f("path/to/sql.sql", input$user_input)
  tbl <- RJDBC::dbGetQuery(conx, query)
  write.csv(tbl)
}) |> bindEvent(input$button_1)

2. Would fail

myTable <- reactive({
  # Consider conx properly defined in an external file invoked by source()
  query <- f("path/to/sql.sql", input$user_input)
  tbl <- RJDBC::dbGetQuery(conx, query)
  tbl
}) |> bindEvent(input$button_2)

Further Info

This is the dockerfile I used. Also tried with a very similar one using nixos/nix base docker image

FROM ubuntu:jammy

COPY generate_env.R .

RUN apt update -y

RUN apt install curl -y

RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux \
  --extra-conf "sandbox = false" \
  --init none \
  --no-confirm

# Adds Nix to the path, as described by the Determinate Systems installer's documentation
ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin"

RUN nix-channel --update

RUN nix-shell \
    --expr "$(curl -sl https://raw.githubusercontent.com/ropensci/rix/master/inst/extdata/default.nix)" \
    --run "Rscript generate_env.R"

RUN nix-build

EXPOSE 3838

COPY . /app

RUN chmod 777 -R /app

CMD ["nix-shell", "--run", "R CMD javareconf && Rscript /app/run-app.R"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions