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?
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.