Forum: JRuby JRuby Threading and Database Connection

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Chris G. (Guest)
on 2009-04-26 22:19
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.
Chris G. (Guest)
on 2009-04-26 22:28
Attachment: stackoverflow.txt (0 Bytes)
I attached the full stackoverflow. It seems that the application run
into some sort of infinite loop at:
attribute_methods.rb:249
Chris G. (Guest)
on 2009-04-26 23:00
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:in
`const_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:in
`spawn'
/Users/Chris/Documents/prog/aptana_workspace/SWAN/vendor/plugins/spawn/lib/spawn.rb:136:in
`thread_it' :1:in `escapeHTML'
This topic is locked and can not be replied to.