Skip to content

RJB freeze on Docker loading classes #84

@NathanReis

Description

@NathanReis

I have a project where the RJB can load Java classes locally without any problem, but when I run it in a container it freezes.

My RJB config (always work locally):

Rails.application.configure do
  config.to_prepare do
    jar_paths = [
      'bin/dfe-distribuicao.jar', PoiSpreadsheet.jar_paths
    ].join(':')

    max_heap = "-Xmx#{ENV['JVM_MAX_HEAP'] || '1024M'}"
    jvm_args = [max_heap]
    Rjb::load(jar_paths, jvm_args)
  end
end

I've already tested replacing config.to_prepare with config.after_initialize, and even loading my classes just below Rjb::load, but it keeps freezing.

My current RJB config (yet doesn't work on Docker):

Rails.application.configure do
  config.after_initialize do
    jar_paths = [
      'bin/dfe-distribuicao.jar', PoiSpreadsheet.jar_paths
    ].join(':')

    max_heap = "-Xmx#{ENV['JVM_MAX_HEAP'] || '1024M'}"
    jvm_args = [max_heap, '-Xrs']
    Rjb::load(jar_paths, jvm_args)

    Rjb.classes['org.apache.poi.xssf.usermodel.XSSFWorkbook'] || Rjb.import('org.apache.poi.xssf.usermodel.XSSFWorkbook')
    Rjb.classes['org.apache.poi.xssf.streaming.SXSSFWorkbook'] || Rjb.import('org.apache.poi.xssf.streaming.SXSSFWorkbook')
    Rjb.classes['org.apache.poi.ss.usermodel.CellType'] || Rjb.import('org.apache.poi.ss.usermodel.CellType')
    Rjb.classes['java.io.FileOutputStream'] || Rjb.import('java.io.FileOutputStream')
  end
end

My Java Settings in Container:

ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

# Fixing RJB Issue: https://github.com/arton/rjb/issues/70
RUN cd ${JAVA_HOME} && mkdir -p jre/lib/amd64 && ln -s ${JAVA_HOME}/lib/server ${JAVA_HOME}/jre/lib/amd64/server

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions