Aspose Cells Docker

I’m currently experiencing an issue with the Aspose Cells Java Library while running it within a Ruby on Rails application. The environment setup includes Phusion Passenger, Nginx, and Docker. To integrate the Aspose Cells library, I’m using the Ruby Java Bridge (Rjb) gem.

Problem Description

Whenever I attempt to load a workbook from a template, Rjb freezes. I have monitored the memory consumption, and it seems that Rjb utilizes some memory which it never releases. Consequently, when I try to generate a PDF using Aspose Cells, the request to the endpoint never completes, indicating what seems like a memory leak.

Environment Details

  • Java Version:

    1 java 18.0.1.1 2022-04-22
    2 Java(TM) SE Runtime Environment (build 18.0.1.1+2-6)
    3 Java HotSpot(TM) 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)
    
  • Ruby on Rails Setup:

    • Ruby 2.6.8
    • Phusion Passenger ruby:2.6
    • Nginx
    • Docker
  • Gem:

    • Ruby Java Bridge (Rjb) (~> 1.7, >= 1.7.3)

Steps to Reproduce

  1. Load a workbook from a template using Aspose Cells.
  2. Attempt to generate a PDF from the loaded workbook.

Observations

  • Rjb freezes during the workbook loading process.
  • Memory consumption increases but memory is not freed.
  • The endpoint request to generate a PDF never completes.

Request

Any assistance in diagnosing and resolving this memory issue would be greatly appreciated. If further information or code snippets are required, I am happy to provide them.

Thank you for your support!

@juanb23
Would you like to provide your sample files and test code? We will check it soon.

1 Like

Below is an example of how we are loading the workbook in our code base. This is running inside of a docker containers with JDK 18 installed.

workbook = Rjb::import('com.aspose.cells.Workbook').new(AtEngine::Engine.root.join('spec', 'lib', 'test_objects', 'DerpaReportTemplate.xlsx').to_s)

When the code above runs code execution gets stuck here. There are no further logs or errors code execution just hangs there. The memory of the container increases but is never freed.

Our initializer configures the Apose cell jar as well as the lisence:

require 'rjb'
require 'logger'

logger = Logger.new(STDOUT)
logger.level = Logger::INFO

classpath = ::Dir.glob(AtEngine::Engine.root.join('jars', '**', '*.jar').to_s).join(':')
jvmargs = [
  '-Djava.awt.headless=true',
  '-Xmx2048m',
  '-Xms512m',
  '-XX:+UnlockExperimentalVMOptions',
  '-XX:+UseCGroupMemoryLimitForHeap'
]

begin
  Rjb::load(classpath, jvmargs)
  logger.info("RJB loaded successfully with classpath: #{classpath}")
rescue => e
  logger.error("Failed to load RJB: #{e.message}")
  raise
end

# Verify RJB is working by importing a basic Java class
begin
  string_class = Rjb::import('java.lang.String')
  logger.info("RJB is working correctly. Successfully imported java.lang.String")
rescue => e
  logger.error("RJB verification failed: #{e.message}")
  raise
end

begin
  aspose_license_file = ENV.fetch('ASPOSE_CELLS_JAVA_LICENSE_PATH') { '/path/to/Aspose.Cells.Java.lic' }
  
  if File.exist?(aspose_license_file)
    fstream = Rjb::import('java.io.FileInputStream').new(aspose_license_file)
    license = Rjb::import('com.aspose.cells.License').new()
    license.setLicense(fstream)
    logger.info("Aspose license loaded successfully from: #{aspose_license_file}")
  else
    logger.warn("Aspose license file not found: #{aspose_license_file}")
  end
rescue => e
  logger.error("Failed to load Aspose license: #{e.message}")
end

logger.info("RJB initialization completed")

@juanb23
Would you like to share your sample file named “DerpaReportTemplate.xlsx”? You can compress the file into zip format and upload it here. If the file is too large to upload, you can also upload it to a cloud drive and share the link here. We will check it soon.

I will verify that I can share the file with you and send it over if so. If not, we can send over a similar file that has the same issue.

However, the file most likely will not be the issue in my opinion. The file loads successfully when running the code on our host machines. Only when in docker do we run into these issues.

@juanb23
Thanks for your feedback. We will evaluate your issue further and get back to you soon.

@juanb23

Please share us a runnable project with docker file and detail steps to reproduce your issue.