Error using AMFServiceProvider

9 views
Skip to first unread message

Dariel Subiros

unread,
Jan 17, 2011, 5:44:55 PM1/17/11
to restfulx-framework
Hi Dima:

I was testing restfulx-1.3.1, and began to use AMF by the first time
and threw this error when calling the server:

An ActionScript error has occurred:
TypeError: Error #1034: Type Coercion failed: cannot convert
Object@9fa42b09 to org.restfulx.models.RxModel.
at org.restfulx.serializers::AMFSerializer/cacheItem()[/media/Data/
Docs/0_PROGRAMMING/FLEX_RUBY_RAILS/RestfulX/releases/1.3.1/FIXED_BUGS/
dima-restfulx_framework-3328058/framework/src/org/restfulx/serializers/
AMFSerializer.as:63]
at org.restfulx.serializers::AMFSerializer/unmarshall()[/media/Data/
Docs/0_PROGRAMMING/FLEX_RUBY_RAILS/RestfulX/releases/1.3.1/FIXED_BUGS/
dima-restfulx_framework-3328058/framework/src/org/restfulx/serializers/
AMFSerializer.as:47]
at org.restfulx.services.amf::AMFServiceProvider/unmarshall()[/media/
Data/Docs/0_PROGRAMMING/FLEX_RUBY_RAILS/RestfulX/releases/1.3.1/
FIXED_BUGS/dima-restfulx_framework-3328058/framework/src/org/restfulx/
services/amf/AMFServiceProvider.as:110]
at org.restfulx.services::ServiceResponder/result()[/media/Data/Docs/
0_PROGRAMMING/FLEX_RUBY_RAILS/RestfulX/releases/1.3.1/FIXED_BUGS/dima-
restfulx_framework-3328058/framework/src/org/restfulx/services/
ServiceResponder.as:95]
at Function/<anonymous>()[/media/Data/Docs/0_PROGRAMMING/
FLEX_RUBY_RAILS/RestfulX/releases/1.3.1/FIXED_BUGS/dima-
restfulx_framework-3328058/framework/src/org/restfulx/services/http/
XMLHTTPServiceProvider.as:406]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

I have tested using default ServiceProvider and works just fine, and
when changing the provider to AMF this happened.

Today I downloaded the source code of the framework and compiled it,
but was the same.
Another question:
I'm creating a program and any provider works for me, but: is better/
faster AMF than JSON and XML?

Thanks Dima.

Dima Berastau

unread,
Jan 17, 2011, 6:07:03 PM1/17/11
to restfulx-...@googlegroups.com
Hi Dariel,

You probably forgot to configure something on your Rails side:

E.g. check out config/initializers/restfulx.rb

and make sure you actually have the mapping defined:

# Set up the default namespace for serializing Rails models to AMF
RestfulX::AMF::ClassMapper.default_as_prefix = "yourflexpackage.models"

This should be a good example for how to set up AMF in your Rails2 project:

https://github.com/dima/air_amf_sync

Hope this helps,
Dima

> --
> You received this message because you are subscribed to the Google Groups "restfulx-framework" group.
> To post to this group, send email to restfulx-...@googlegroups.com.
> To unsubscribe from this group, send email to restfulx-framew...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/restfulx-framework?hl=en.
>

Dariel Subiros

unread,
Jan 18, 2011, 2:14:05 PM1/18/11
to restfulx-...@googlegroups.com
Hi Dima:

Thanks for your quick answer. That was exactly the problem. After all this was the first time I tried to use AMF with restfulx, so this post may be helpful for others in their first time too.

Besides that I still had an issue in my program, and was because of this:

To use amf responder I duplicated for example the line format.fxml { render :fxml => @node } and changed fxml for amf as supposed, but in some cases I was using too @node.to_fxml() and forgot to replace it by amf there, but digging in code I realized about that.

Keep doing this job, because there's nothing better than this awesome framework in all the world.
Thanks for all of your help.

Dariel

Zdravko Gligic

unread,
Jan 18, 2011, 2:19:59 PM1/18/11
to restfulx-...@googlegroups.com
Folks,

Is RestfulX applicable for purely Flex/AS3 and CouchDB use cases -
without any Ruby/Rails nor even any web servers between the flash
client and the CouchDb server ?

Thanks,
Zdravko

Dima Berastau

unread,
Jan 18, 2011, 2:52:28 PM1/18/11
to restfulx-...@googlegroups.com
Hi Zdravko,

In general yes, but please refer to https://github.com/dima/restfulx_framework/wiki/Using-CouchDB-in-Flex-AIR-with-RestfulX
for more details as there are some caveats.

Dima

Dariel Subiros

unread,
Jan 19, 2011, 3:59:25 PM1/19/11
to restfulx-...@googlegroups.com
Hi guys:

I'm already using amf successfully with almost all of my models, but I got this error with one of them:

This is the trace of rails server:

Processing NodeContainersController#index to amf (for 127.0.0.1 at 2011-01-21 15:49:34) [GET]
  Parameters: {"format"=>"amf", "action"=>"index", "page"=>"1", "controller"=>"node_containers", "per_page"=>"3"}
  NodeContainer Load (19.8ms)   SELECT * FROM `node_containers` 
  NodeContainer Columns (1.6ms)   SHOW FIELDS FROM `node_containers`
  Node Load (34.5ms)   SELECT * FROM `nodes` WHERE (`nodes`.node_container_id = 124689896) ORDER BY updated_at DESC
  Node Columns (1.4ms)   SHOW FIELDS FROM `nodes`
DEPRECATION WARNING: ActiveRecord::Base#class_name is deprecated and will be removed in Rails 2.3.9. (called from serialize_record at /usr/lib/ruby/gems/1.8/gems/restfulx-1.3.1/lib/restfulx/amf/pure/serializer.rb:162)

TypeError (can't convert Symbol into Array):
  restfulx (1.3.1) lib/restfulx/rx_active_record.rb:207:in `concat'
  restfulx (1.3.1) lib/restfulx/rx_active_record.rb:207
  restfulx (1.3.1) lib/restfulx/amf/pure/serializer.rb:193:in `call'
  restfulx (1.3.1) lib/restfulx/amf/pure/serializer.rb:193:in `serialize_record'
  restfulx (1.3.1) lib/restfulx/rx_active_record.rb:206:in `serialize'
  restfulx (1.3.1) lib/restfulx/rx_active_record.rb:277:in `to_amf'
  restfulx (1.3.1) lib/restfulx/amf/pure/serializer.rb:212:in `serialize_records'
  restfulx (1.3.1) lib/restfulx/amf/pure/serializer.rb:210:in `each'
  restfulx (1.3.1) lib/restfulx/amf/pure/serializer.rb:210:in `serialize_records'
  restfulx (1.3.1) lib/restfulx/amf/pure/serializer.rb:107:in `serialize_models_array'
  restfulx (1.3.1) lib/restfulx/rx_active_record.rb:252:in `add_associations'
  restfulx (1.3.1) lib/restfulx/rx_active_record.rb:214
  restfulx (1.3.1) lib/restfulx/rx_active_record.rb:213
  restfulx (1.3.1) lib/restfulx/amf/pure/serializer.rb:193:in `call'
  restfulx (1.3.1) lib/restfulx/amf/pure/serializer.rb:193:in `serialize_record'
  restfulx (1.3.1) lib/restfulx/rx_active_record.rb:206:in `serialize'
  restfulx (1.3.1) lib/restfulx/rx_active_record.rb:277:in `to_amf'
  restfulx (1.3.1) lib/restfulx/amf/pure/serializer.rb:212:in `serialize_records'
  restfulx (1.3.1) lib/restfulx/amf/pure/serializer.rb:210:in `each'
  restfulx (1.3.1) lib/restfulx/amf/pure/serializer.rb:210:in `serialize_records'
  restfulx (1.3.1) lib/restfulx/amf/pure/serializer.rb:117:in `serialize_typed_array'
  restfulx (1.3.1) lib/restfulx/rx_active_support.rb:125:in `to_amf'
  app/controllers/node_containers_controller.rb:19
  app/controllers/node_containers_controller.rb:13:in `index'
  config/initializers/restfulx.rb:18:in `call'
  config/initializers/restfulx.rb:40:in `call'
  /usr/lib/ruby/1.8/mongrel.rb:159:in `process_client'
  /usr/lib/ruby/1.8/mongrel.rb:158:in `each'
  /usr/lib/ruby/1.8/mongrel.rb:158:in `process_client'
  /usr/lib/ruby/1.8/mongrel.rb:285:in `run'
  /usr/lib/ruby/1.8/mongrel.rb:285:in `initialize'
  /usr/lib/ruby/1.8/mongrel.rb:285:in `new'
  /usr/lib/ruby/1.8/mongrel.rb:285:in `run'
  /usr/lib/ruby/1.8/mongrel.rb:268:in `initialize'
  /usr/lib/ruby/1.8/mongrel.rb:268:in `new'
  /usr/lib/ruby/1.8/mongrel.rb:268:in `run'

Call the same using fxml/json and works well. So it seems is a amf stuff.

Thanks.
Dariel

Dima Berastau

unread,
Jan 19, 2011, 4:16:34 PM1/19/11
to restfulx-...@googlegroups.com
This is also best put into a bug report with some sample code to look at.

Thanks,
Dima

>>>>>> restfulx-framew...@googlegroups.com<restfulx-framework%2Bunsu...@googlegroups.com>


>> .
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/restfulx-framework?hl=en.
>>>>>>
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>> Groups
>>>>> "restfulx-framework" group.
>>>>> To post to this group, send email to
>> restfulx-...@googlegroups.com.
>>>>> To unsubscribe from this group, send email to

>>>>> restfulx-framew...@googlegroups.com<restfulx-framework%2Bunsu...@googlegroups.com>


>> .
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/restfulx-framework?hl=en.
>>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>> Groups
>>>> "restfulx-framework" group.
>>>> To post to this group, send email to
>> restfulx-...@googlegroups.com.
>>>> To unsubscribe from this group, send email to

>>>> restfulx-framew...@googlegroups.com<restfulx-framework%2Bunsu...@googlegroups.com>


>> .
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/restfulx-framework?hl=en.
>>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>> "restfulx-framework" group.
>>> To post to this group, send email to restfulx-...@googlegroups.com
>> .
>>> To unsubscribe from this group, send email to

>> restfulx-framew...@googlegroups.com<restfulx-framework%2Bunsu...@googlegroups.com>


>> .
>>> For more options, visit this group at
>> http://groups.google.com/group/restfulx-framework?hl=en.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "restfulx-framework" group.
>> To post to this group, send email to restfulx-...@googlegroups.com.
>> To unsubscribe from this group, send email to

>> restfulx-framew...@googlegroups.com<restfulx-framework%2Bunsu...@googlegroups.com>

Reply all
Reply to author
Forward
0 new messages