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.
Has anyone found a solution to this? I’m running into the same problem.
Matthew P. 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
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:
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