
Issue on Rails 2.3.5 - TypeError (compared with non class/module):
Reported by John Woodell | January 7th, 2010 @ 08:54 PM | in 1.0.0
Rails 2.3.5 is not working with DM (on GAE)
TypeError (compared with non class/module):
bundler_gems/jruby/1.8/gems/extlib-0.9.14/lib/extlib/hook.rb:264:in
execute_before_create_hook_nan_hook_stack'
bundler_gems/jruby/1.8/gems/extlib-0.9.14/lib/extlib/hook.rb:298:in
create_hook'
bundler_gems/jruby/1.8/gems/extlib-0.9.14/lib/extlib/hook.rb:297:in
catch'
bundler_gems/jruby/1.8/gems/extlib-0.9.14/lib/extlib/hook.rb:297:in
create_hook'
bundler_gems/jruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:925:in
save_self'
bundler_gems/jruby/1.8/gems/dm-validations-0.10.2/lib/dm-validations.rb:61:in
save_self'
bundler_gems/jruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:912:in
_save'
bundler_gems/jruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:1085:in
run_once'
bundler_gems/jruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:911:in
_save'
bundler_gems/jruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:351:in
save'
bundler_gems/jruby/1.8/gems/dm-validations-0.10.2/lib/dm-validations.rb:48:in
save'
bundler_gems/jruby/1.8/gems/dm-validations-0.10.2/lib/dm-validations/support/context.rb:30:in
validation_context'
bundler_gems/jruby/1.8/gems/dm-validations-0.10.2/lib/dm-validations.rb:48:in
save'
app/controllers/articles_controller.rb:46:in
create'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/mime_responds.rb:106:in
call'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/mime_responds.rb:106:in
respond_to'
app/controllers/articles_controller.rb:45:in create'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1331:in
perform_action'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:617:in
call_filters'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:610:in
perform_action_with_filters'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in
perform_action_with_benchmark'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in
perform_action_with_benchmark'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:160:in
perform_action_with_rescue'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/flash.rb:146:in
perform_action_with_flash'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in
process'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:606:in
process_with_filters'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:391:in
process'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:386:in
call'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in
call'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in
dispatch'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:121:in
_call'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in
build_middleware_stack'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in
call'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in
call'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in
call'
file:WEB-INF/lib/jruby-rack-0.9.6-SNAPSHOT.jar!/action_controller/session/java_servlet_store.rb:48:in
call'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in
call'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:114:in
call'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/reloader.rb:34:in
run'
bundler_gems/jruby/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in
call'
bundler_gems/jruby/1.8/gems/rails-2.3.5/lib/rails/rack/static.rb:31:in
call'
bundler_gems/jruby/1.8/gems/rails-2.3.5/lib/rails/rack/log_tailer.rb:17:in
call'
file:WEB-INF/lib/jruby-rack-0.9.6-SNAPSHOT.jar!/rack/handler/servlet.rb:18:in
call' :1
Comments and changes to this ticket
-
John Woodell January 9th, 2010 @ 01:43 AM
On Fri, Jan 8, 2010 at 9:49 PM, Josh Moore joshsmoore@gmail.com wrote:
I am not sure how far you have gotten in your investigation. But, I thought I would share what I have so far because I am stuck now. DataMapper creates a hook method that is run when the model is saved for the first time. This method, amongst other things, calls "create_hook" then calls the "execute_before_create_hook_nan_hook_stack" also dynamically generated. The "execute_before_create_hook_nan_hook_stack" method ony does one thing it runs this line of code:set_timestamps_on_save() if self.class <= ObjectSpace._id2ref(1733349204)
As far as I can tell it does the if check because each hook method can be given a particular scope. So the if statement (I think) checks the scope to make sure it is correct. The problem is that the ObjectSpace.id2ref(<object_id>) does not returned the excepted class that represents the hook's scope. Instead it either returns nil or a Fixnum (at least that is what I have seen so far). So for some reason the id of class that represents the scope returns either a nil or a Fixnum (usually a fixnum) when it is searched for by the id2ref method. I have even tried running the dev_appserver with ObjectSpace enabled and I still get the same problem. This is the part that is stumping me. Any ideas?
Another interesting aspect of this problem is that it works fine in the console (appcfg.rb -r '.gems/bundler_gems/environment' run script/console
-
John Woodell January 11th, 2010 @ 03:47 PM
ObjectSpace is disabled with JRuby 1.5. Headius says...
"datamapper should not use [ObjectSpace], for sure it's new in 1.5 that we've disabled id2ref because previously whenever you'd call Object#id or #object_id we'd have to save the ID plus a weak reference so id2ref calls later would work which made #id and #object_id dreadfully slow and since they're used by lots of people as a unique key..."
Unfortunately, extlib fails in the inline_call method...
http://github.com/datamapper/extlib/blob/master/lib/extlib/hook.rb#...
%(#{name}(#{args}) if self.class <= ObjectSpace._id2ref(#{method_info[:from].object_id}))~extlib-0.9.14/lib/extlib/hook.rb:264 warning: ObjectSpace is disabled; _id2ref only supports immediates, pass -X+O to enable
-
-
John Woodell January 25th, 2010 @ 09:58 AM
Josh Moore has patched this issue from within an integration plugin, please take a look:
Override Extlib::Hook::ClassMethods.inline_call to check in the given weak reference
http://github.com/woodie/dm-rails-gae/blob/master/lib/rails_dm_data...
-
Dan Kubb (dkubb) April 10th, 2010 @ 12:41 AM
- State changed from new to resolved
- Milestone set to 1.0.0
This should now be resolved in edge dm-core. ObjectSpace is no longer being used.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »