You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that JRuby 9.0.1.0 still has problems autoloading constants under certain conditions. We noticed this issue quite a bit on JRuby 1.7.something, to a certain extend it still seems to occur on 9.0.1.0 (though less often).
The problem is basically as following: we run numerous Ruby applications on JRuby for sentiment analysis (various applications bind to Java code, hence JRuby). All these applications use the AWS SDK (a recurring source of headaches at this point). The AWS SDK in turn autoloads pretty much everything, it also dynamically defines a bunch of classes based on AWS API responses if I remember correctly (though this seems unrelated to the problem at hand). In certain instances the AWS code will throw a NameError when it can't find a certain constant. For example (stacktrace is from Rollbar, hence the somewhat odd formatting):
NameError: uninitialized constant Aws::Xml::Parser::Stack::Frame
File "org/jruby/RubyModule.java" line 3166 in const_missing
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/aws-sdk-core/xml/parser/stack.rb" line 48 in child_frame
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/aws-sdk-core/xml/parser/stack.rb" line 17 in start_element
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/aws-sdk-core/xml/parser/engines/oga.rb" line 21 in on_element
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oga-1.3.1-java/lib/oga/xml/sax_parser.rb" line 170 in run_callback
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oga-1.3.1-java/lib/oga/xml/sax_parser.rb" line 94 in on_element
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oga-1.3.1-java/lib/oga/xml/parser.rb" line 507 in _rule_27
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oga-1.3.1-java/lib/oga/xml/parser.rb" line 239 in block in each_token
File "org/jruby/RubyProc.java" line 308 in call
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oga-1.3.1-java/lib/oga/xml/lexer.rb" line 237 in add_token
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oga-1.3.1-java/lib/oga/xml/lexer.rb" line 398 in add_element
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oga-1.3.1-java/lib/oga/xml/lexer.rb" line 369 in on_element_name
File "org/liboga/xml/Lexer.java" line 836 in advance_native
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oga-1.3.1-java/lib/oga/xml/lexer.rb" line 190 in block in advance
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oga-1.3.1-java/lib/oga/xml/lexer.rb" line 137 in read_data
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oga-1.3.1-java/lib/oga/xml/lexer.rb" line 189 in advance
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oga-1.3.1-java/lib/oga/xml/parser.rb" line 236 in each_token
File "org/libll/Driver.java" line 303 in parse
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oga-1.3.1-java/lib/oga/xml/parser.rb" line 269 in parse
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oga-1.3.1-java/lib/oga/oga.rb" line 35 in sax_parse_xml
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/aws-sdk-core/xml/parser/engines/oga.rb" line 14 in parse
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/aws-sdk-core/xml/parser.rb" line 29 in parse
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/aws-sdk-core/query/handler.rb" line 53 in parse_xml
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/aws-sdk-core/query/handler.rb" line 29 in block in call
File "org/jruby/RubyProc.java" line 308 in call
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/seahorse/client/response.rb" line 43 in block in on
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/seahorse/client/http/response.rb" line 139 in block in on_success
File "org/jruby/RubyProc.java" line 308 in call
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/seahorse/client/http/response.rb" line 166 in block in listener
File "org/jruby/RubyProc.java" line 308 in call
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/seahorse/client/http/response.rb" line 130 in on_done
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/seahorse/client/http/response.rb" line 137 in on_success
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/seahorse/client/response.rb" line 42 in on
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/seahorse/client/response.rb" line 51 in on_success
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/aws-sdk-core/query/handler.rb" line 27 in call
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/aws-sdk-core/plugins/user_agent.rb" line 12 in call
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/seahorse/client/plugins/endpoint.rb" line 34 in call
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/aws-sdk-core/plugins/param_validator.rb" line 21 in call
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/seahorse/client/plugins/raise_response_errors.rb" line 14 in call
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/aws-sdk-core/plugins/param_converter.rb" line 21 in call
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/seahorse/client/plugins/response_target.rb" line 21 in call
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/seahorse/client/request.rb" line 70 in send_request
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/aws-sdk-core-2.1.19/lib/seahorse/client/base.rb" line 207 in block in get_queue_url
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oni-4.0.0/lib/oni/daemons/sqs.rb" line 63 in queue_url
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oni-4.0.0/lib/oni/daemons/sqs.rb" line 55 in queue
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oni-4.0.0/lib/oni/daemons/sqs.rb" line 34 in receive
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oni-4.0.0/lib/oni/daemon.rb" line 174 in run_thread
File "/usr/local/rvm/gems/jruby-9.0.1.0/gems/oni-4.0.0/lib/oni/daemon.rb" line 158 in block in spawn_thread
The interesting thing here is that it seems the AWS code is trying to load the constant relative to the wrong root constant. That is, the Frame class is loaded from Aws::Xml::Parser::Stack while it's actually defined in Aws::Xml::Parser. Prior to updating this code to version 2 of the AWS SDK I had similar issues where the code was trying to load the class AWS::SQS::Queue but would end up using the top-level Queue class, resulting in an ArgumentError when the class was initialized (as AWS::SQS::Queue#initialize has an arity of 2).
Sadly Rollbar didn't actually track what application this error originated from (don't get me started). However, the exception occurs during bootup when it tries to connect to the AWS queue. Since all applications use the same bootup phase this should be possible to reproduce using any of them.
Thankfully the code is (for a change) open source. As such you should be able to reproduce this as following:
You'll need to have an AWS account and set the environment variables AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_REGION
Run the script setup.rb as noted below
gem install opener-language-identifier, you'll need to have libarchive installed if I remember correctly
run language-identifier-daemon, terminate it and repeat this process until the error occurs (this is basically where you'll need a lot of luck)
setup.rb:
# gem install aws-sdkrequire'aws-sdk'sqs=Aws::SQS::Client.newresponse=sqs.create_queue(:queue_name=>'opener-language-identifier')puts"Created queue with URL #{response.queue_url}"
Alternatively, if you want to also test the runtime for any autoloading problems, use the following setup script instead:
# gem install aws-sdkrequire'aws-sdk'require'json'sqs=Aws::SQS::Client.newsqs.create_queue(:queue_name=>'opener-output')response=sqs.create_queue(:queue_name=>'opener-language-identifier')puts"Created queue with URL #{response.queue_url}"payload=JSON.dump(:identifier=>'123',:input_url=>'https://s3-eu-west-1.amazonaws.com/storage.olery.com/olery-jruby-autoloading-review.txt',:callbacks=>['sqs://opener-output'])1000.timesdosqs.send_message(:queue_url=>response.queue_url,:message_body=>review)end
Then, instead of terminating the language-identifier-daemon command right away just let it run. If you're on a laptop you might want to take it off your lap, because it's probably going to get very hot.
The text was updated successfully, but these errors were encountered:
Same happens with rails master (rails 5) on the jruby 9.0.1.0 (jruby 9.0.1.0 (2.2.2) 2015-09-02 583f336 Java HotSpot(TM) 64-Bit Server VM 24.65-b04 on 1.7.0_67-b01 +jit [darwin-x86_64]).
Rails 5 edge is able to boot and run on JRuby now, so if the Rails 5 case we indicative this appears to be working fine in 9.1. If someone can reproduce this again we'd be all over investigating it again.
It appears that JRuby 9.0.1.0 still has problems autoloading constants under certain conditions. We noticed this issue quite a bit on JRuby 1.7.something, to a certain extend it still seems to occur on 9.0.1.0 (though less often).
The problem is basically as following: we run numerous Ruby applications on JRuby for sentiment analysis (various applications bind to Java code, hence JRuby). All these applications use the AWS SDK (a recurring source of headaches at this point). The AWS SDK in turn autoloads pretty much everything, it also dynamically defines a bunch of classes based on AWS API responses if I remember correctly (though this seems unrelated to the problem at hand). In certain instances the AWS code will throw a NameError when it can't find a certain constant. For example (stacktrace is from Rollbar, hence the somewhat odd formatting):
The file in question: https://github.com/aws/aws-sdk-ruby/blob/9eeeb192565e4ed97a427e9e95d99b922274ea42/aws-sdk-core/lib/aws-sdk-core/xml/parser/stack.rb#L48
Autoload is defined here: https://github.com/aws/aws-sdk-ruby/blob/5929ddfb7266961f5acc8fb189685bc1178ba19f/aws-sdk-core/lib/aws-sdk-core/xml/parser.rb#L7-L8
The interesting thing here is that it seems the AWS code is trying to load the constant relative to the wrong root constant. That is, the Frame class is loaded from
Aws::Xml::Parser::Stack
while it's actually defined inAws::Xml::Parser
. Prior to updating this code to version 2 of the AWS SDK I had similar issues where the code was trying to load the classAWS::SQS::Queue
but would end up using the top-levelQueue
class, resulting in an ArgumentError when the class was initialized (asAWS::SQS::Queue#initialize
has an arity of 2).Sadly Rollbar didn't actually track what application this error originated from (don't get me started). However, the exception occurs during bootup when it tries to connect to the AWS queue. Since all applications use the same bootup phase this should be possible to reproduce using any of them.
Thankfully the code is (for a change) open source. As such you should be able to reproduce this as following:
AWS_ACCESS_KEY_ID
,AWS_SECRET_ACCESS_KEY
andAWS_REGION
setup.rb
as noted belowgem install opener-language-identifier
, you'll need to have libarchive installed if I remember correctlylanguage-identifier-daemon
, terminate it and repeat this process until the error occurs (this is basically where you'll need a lot of luck)setup.rb:
Alternatively, if you want to also test the runtime for any autoloading problems, use the following setup script instead:
Then, instead of terminating the
language-identifier-daemon
command right away just let it run. If you're on a laptop you might want to take it off your lap, because it's probably going to get very hot.The text was updated successfully, but these errors were encountered: