Matthew Palmer
2005-Dec-30 06:10 UTC
AWS api_method :returns not accepting ActiveRecord::Base
I''m trying to use the feature of AWS where it will take an object derived from ActiveRecord::Base instead of an AWS::Struct object. Whenever I try it, though, I get the craziest error: NoMethodError: You have a nil object when you didn''t expect it! The error occured while evaluating nil.new /usr/lib/.../actionwebservice/lib/action_web_service/casting.rb:105:in `cast_to_structured_type'' [...] The reason why there''s a nil object instead of a type class object is because something tried to create a StructuredType of Exception, which (strangely!) doesn''t actually work. Changing my type to any of the internals or to a class derived from AWS::Struct causes the problem to disappear. I know I''m a bit short on details, but the full test case is fairly simple to construct -- create an ActiveRecord model, create a basic AWS API, and try to make the API method return the model. If it''s unclear, I''ll whip up a sample example to demonstrate the problem as I see it, but it probably won''t be of a form suitable for inclusion in the test suite, so it''s probably better if people who know about such things build the acceptance test. - Matt -- Non-PHB basically told $MANAGER to go check his drive integrity. -- steve, ASR
Chris Goodwin
2006-May-12 19:52 UTC
[Rails] Re: AWS api_method :returns not accepting ActiveRecord::Base
Has anyone found a solution to this? I''m running into the same problem. Matthew Palmer wrote:> I''m trying to use the feature of AWS where it will take an object > derived > from ActiveRecord::Base instead of an AWS::Struct object. Whenever I > try > it, though, I get the craziest error: > > NoMethodError: You have a nil object when you didn''t expect it! > The error occured while evaluating nil.new > /usr/lib/.../actionwebservice/lib/action_web_service/casting.rb:105:in-- Posted via http://www.ruby-forum.com/.
Kent Sibilev
2006-May-12 20:45 UTC
[Rails] Re: AWS api_method :returns not accepting ActiveRecord::Base
Are you using the latest version? On 5/12/06, Chris Goodwin <chris.goodwin@gmail.com> wrote:> Has anyone found a solution to this? I''m running into the same problem. > > Matthew Palmer wrote: > > I''m trying to use the feature of AWS where it will take an object > > derived > > from ActiveRecord::Base instead of an AWS::Struct object. Whenever I > > try > > it, though, I get the craziest error: > > > > NoMethodError: You have a nil object when you didn''t expect it! > > The error occured while evaluating nil.new > > /usr/lib/.../actionwebservice/lib/action_web_service/casting.rb:105:in > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Kent --- http://www.datanoise.com
Chris Goodwin
2006-May-15 13:03 UTC
[Rails] Re: Re: AWS api_method :returns not accepting ActiveRecord::
I''m running Rails 1.1.2. AWS = 1.1.2. Ruby 1.8.4. The actual error I''m getting appears to be thrown when ActiveRecord is looking up the table definition information after the SOAP call has been made. Here''s the stacktrace: NoMethodError (You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occured while evaluating nil.[]=): c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1889:in `write_attribute'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1380:in `id='' c:/ruby/lib/ruby/1.8/soap/mapping/mapping.rb:298:in `set_attributes'' c:/ruby/lib/ruby/1.8/soap/mapping/mapping.rb:294:in `set_attributes'' c:/ruby/lib/ruby/1.8/soap/mapping/factory.rb:75:in `setiv2struct'' c:/ruby/lib/ruby/1.8/soap/mapping/factory.rb:35:in `setiv2obj'' c:/ruby/lib/ruby/1.8/soap/mapping/rubytypeFactory.rb:442:in `unknownstruct2obj'' c:/ruby/lib/ruby/1.8/soap/mapping/rubytypeFactory.rb:405:in `unknowntype2obj'' c:/ruby/lib/ruby/1.8/soap/mapping/rubytypeFactory.rb:251:in `soap2obj'' c:/ruby/lib/ruby/1.8/soap/mapping/registry.rb:479:in `_soap2obj'' c:/ruby/lib/ruby/1.8/soap/mapping/registry.rb:428:in `soap2obj'' c:/ruby/lib/ruby/1.8/soap/mapping/mapping.rb:146:in `_soap2obj'' c:/ruby/lib/ruby/1.8/soap/mapping/mapping.rb:143:in `_soap2obj'' c:/ruby/lib/ruby/1.8/soap/mapping/mapping.rb:59:in `soap2obj'' c:/ruby/lib/ruby/1.8/soap/mapping/mapping.rb:360:in `protect_threadvars'' c:/ruby/lib/ruby/1.8/soap/mapping/mapping.rb:55:in `soap2obj'' c:/ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.1.2/lib/action_web_service/protocol/soap_protocol/marshaler.rb:31:in `soap_to_ruby'' c:/ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.1.2/lib/action_web_service/protocol/soap_protocol.rb:61:in `decode_request'' c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `collect'' c:/ruby/lib/ruby/1.8/soap/baseData.rb:475:in `each'' c:/ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.1.2/lib/action_web_service/protocol/soap_protocol.rb:61:in `decode_request'' c:/ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.1.2/lib/action_web_service/protocol/soap_protocol.rb:45:in `decode_action_pack_request'' c:/ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.1.2/lib/action_web_service/protocol/discovery.rb:20:in `discover_web_service_request'' c:/ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.1.2/lib/action_web_service/protocol/discovery.rb:18:in `discover_web_service_request'' c:/ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.1.2/lib/action_web_service/dispatcher/action_controller_dispatcher.rb:44:in `dispatch_web_service_request'' (eval):1:in `api'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:910:in `perform_action_without_filters'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/rescue.rb:82:in `perform_action'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:381:in `process_without_filters'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:in `process_without_session_management_support'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:117:in `process'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in `dispatch'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:115:in `handle_dispatch'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:81:in `service'' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:67:in `dispatch'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/servers/webrick.rb:59 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/server.rb:30 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' script/server:3 Kent Sibilev wrote:> Are you using the latest version? > > On 5/12/06, Chris Goodwin <chris.goodwin@gmail.com> wrote: >> > The error occured while evaluating nil.new >> > /usr/lib/.../actionwebservice/lib/action_web_service/casting.rb:105:in >> >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > -- > Kent > --- > http://www.datanoise.com-- Posted via http://www.ruby-forum.com/.
Kent Sibilev
2006-May-15 16:10 UTC
[Rails] Re: Re: AWS api_method :returns not accepting ActiveRecord::
Chris, Can you post a code that triggers this exception? It seems that for some reason your model class is not registered with soup4r mapping. On 5/15/06, Chris Goodwin <chris.goodwin@gmail.com> wrote:> > I''m running Rails 1.1.2. AWS = 1.1.2. Ruby 1.8.4. The actual error > I''m getting appears to be thrown when ActiveRecord is looking up the > table definition information after the SOAP call has been made. Here''s > the stacktrace: > > NoMethodError (You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occured while evaluating nil.[]=): > >-- Kent --- http://www.datanoise.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060515/58d6498a/attachment.html
Chris Goodwin
2006-May-15 22:10 UTC
[Rails] Re: Re: Re: AWS api_method :returns not accepting ActiveReco
Sure. Note that the code is blowing up before the first line of update_test(company) is executed...the logger statement in the first line never gets logged, which suggest that it''s in the marshalling code. The find_by_id method works and returns the object to the calling code, so it seems to only be a problem with the calling code is sending an ActiveRecord object. Also, I tracked down the line in ActiveRecord/base.rb (line 1892) that is causing the error, and apparently @attributes is equal to nil....which is a problem. It looks like something in the marshalling process is supposed to create an instance of @attributes and it''s not happening. The application that calls the service is a C# application. The back-end database is SQL Server, and all of this is running on Windows XP with ruby 1.82. Thanks for the help. ServiceController: class CompanyServiceController < ApplicationController class_inheritable_option :allow_active_record_expects, true wsdl_service_name ''CompanyService'' def find_by_id(id) Company.find(:all, :conditions => [''id = ?'', id]) end def update_test(company) logger.info("test: this line is never displayed") @company = Company.find(company.id) @company.update_attributes(company) end end API definition: class CompanyServiceApi < ActionWebService::API::Base class_inheritable_option :allow_active_record_expects, true api_method :find_by_id, :expects => [:int], :returns => [[Company]] api_method :update_test, :expects => [Company] end Model definition: class Company < ActiveRecord::Base set_table_name "tCompany" belongs_to :enterprise end Kent Sibilev wrote:> Chris, > > Can you post a code that triggers this exception? It seems that for some > reason your model class is not registered with soup4r mapping.-- Posted via http://www.ruby-forum.com/.