JRuby Threading and Database Connection


#1

Hi!

I’ve the following error within a thread in my jruby on rails
application:

spawn thread and catch/rescue exceptions

    spawn do
      begin
        Java::checkout.Files.main main_args.to_java :String
        @version.update_attribute(:status_checkout, 2)
      rescue StandardError => e
        puts "[svnkit] "+e
        puts "[svnkit] "+e.backtrace*" "
        @version.update_attribute(:exception_checkout, e)
      end
    end

The update-attribute-statement won’t work. I get a
StackOverflow-Exception.
But, if I comment out the java-line, the update_attribute-method works
fine.

So during the time that is needed to complete the java-task (checking
out some stuff from subversion-repository), something happens to
thedb-connection but I can’t figure it out.


#2

I attached the full stackoverflow. It seems that the application run
into some sort of infinite loop at:
attribute_methods.rb:249


#3

Ok, I found some new interesting things:

if I call
“puts @version.id
after the java command, it throws the same exception. So something does
not work with this instance-varaible …

I got a missing_constant-error, when I tried this one:

    # spawn thread and catch/rescue exceptions
    spawn do
      begin
        Java::checkout.Files.main main_args.to_java :String
        version = Version.find(2)
        version.update_attribute(:status_checkout, 2)
      rescue StandardError => e
        puts "[svnkit] "+e
        puts "[svnkit] "+e.backtrace*" "
        @version.update_attribute(:exception_checkout, e)
      end
    end

/Users/Chris/.gem/jruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:414:in
load_missing_constant' /Users/Chris/.gem/jruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:96:inconst_missing’
/Users/Chris/Documents/prog/aptana_workspace/SWAN/app/controllers/checkout_controller.rb:56:in
perform' /Users/Chris/Documents/prog/aptana_workspace/SWAN/vendor/plugins/spawn/lib/spawn.rb:49:inspawn’
/Users/Chris/Documents/prog/aptana_workspace/SWAN/vendor/plugins/spawn/lib/spawn.rb:136:in
thread_it' :1:inescapeHTML’