Migration problems in production mode with JRuby and threadsafe mode

In production mode there is a problem if you have  enabled threadsafe mode.

To activate  threadsafe mode you need to uncomment this line in config/environments/production.rb# Enable threaded mode
config.threadsafe!

After that add this line to fix migration problems in production mode:

# Allow rake tasks to autoload models in thread safe mode, more info at http://stackoverflow.com/a/4880253

config.dependencyloading = true if $railsraketask


I also have set config.autoloadpaths which does not work with JRuby (found here). You have to add this code after the autoload statement in your config/application.rb

 # when threadsafe is enabled (i.e. JRuby max runtimes 1 does this) then classes/modules
# in lib needs to loaded through some mechanism other than autoloadpaths

config.autoloadpaths.each do |path|
config.eagerloadpaths << path
endThe only other way seems to be to explicitly require those files.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *