Rails: Segmentation fault at Rjb when in background process, works fine when not in background?

Go To StackoverFlow.com

7

I am running a Resque background task and keep getting segmentation fault, when calling a gem, that uses Rjb. Everything works fine though, when run not in the background. Here is a line in gem, that causes the error:

def self.rjb_initialize
  return if ::Rjb::loaded?
  ::Rjb::load(nil, self.jvm_args) #THIS IS WHERE THE ERROR TRACES TO
  set_java_logging if self.log_file
end

The gem loads .jar files as you can see, but again, everything works perfectly, when not in background. What can cause the problem and is it possible to fix it?

2012-04-04 00:03
by Stpn


0

Given the error seems to fail while running as a background task, this is most likely due to environmental variables not being set. According to the docs, both LD_LIBRARY_PATH and JAVA_HOME settings are required in order to use rjb in Rails. I think you can just add them to your environment.rb and ensure the task 'resque:setup' => :environment is used to load the Rails environment.

2015-02-04 06:35
by Marc