Anupam Gupta
Anupam Gupta

Reputation: 1687

Unknown AMF type '16':issue in using arraycollection at java end recieved from flex end using AMF

while calling a java side function from flex side I am having following problem

this works

java side

//in FlexService class
public List<Car> javaFunction(String model){
 return carList;
}

flex side

flexService.javaFunction("merc");

while this doesn't work

java side

//in FlexService.java class
public List<Car> javaFunction(String model, List engine){
 //some code
 return carList;
}

flex side

var engines:ArrayCollection= new ArrayCollection(engineList);

flexService.javaFunction("merc",engines);//function call to java side method

I am getting AMF 16 error.Why I am not able to send ArrayCollection when I can send String.

I referenced http://livedocs.adobe.com/blazeds/1/blazeds_devguide/help.html?content=serialize_data_3.html and it says arraycollection can be received in List..DO I need to create a seperate DTO.??

following is stack trace

2011-10-06 19:57:55,209       83442 [http-8080-5] DEBUG (AbstractUrlHandlerMapping.java:221)- Mapping [/amf] to HandlerExecutionChain with handler [flex.messaging.MessageBroker@13
00800] and 1 interceptor
[BlazeDS]10/06/2011 19:57:55.211 [ERROR] [Endpoint.AMF] Unknown AMF type '16'.
flex.messaging.io.UnknownTypeException: Unknown AMF type '16'.
        at flex.messaging.io.amf.Amf3Input.readObjectValue(Amf3Input.java:219)
        at flex.messaging.io.amf.Amf3Input.readObject(Amf3Input.java:132)
        at flex.messaging.io.amf.Amf3Input.readArray(Amf3Input.java:371)
        at flex.messaging.io.amf.Amf3Input.readObjectValue(Amf3Input.java:157)
        at flex.messaging.io.amf.Amf3Input.readObject(Amf3Input.java:132)
        at flex.messaging.io.amf.Amf3Input.readScriptObject(Amf3Input.java:473)
        at flex.messaging.io.amf.Amf3Input.readObjectValue(Amf3Input.java:153)
        at flex.messaging.io.amf.Amf3Input.readObject(Amf3Input.java:132)
        at flex.messaging.io.amf.Amf0Input.readObjectValue(Amf0Input.java:135)
        at flex.messaging.io.amf.Amf0Input.readArrayValue(Amf0Input.java:326)
        at flex.messaging.io.amf.Amf0Input.readObjectValue(Amf0Input.java:139)
        at flex.messaging.io.amf.Amf0Input.readObject(Amf0Input.java:95)
        at flex.messaging.io.amf.AmfMessageDeserializer.readObject(AmfMessageDeserializer.java:226)
        at flex.messaging.io.amf.AmfMessageDeserializer.readBody(AmfMessageDeserializer.java:205)
        at flex.messaging.io.amf.AmfMessageDeserializer.readMessage(AmfMessageDeserializer.java:125)
        at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:114)
        at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:278)
        at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$8d427d7d.service(<generated>)
        at

Upvotes: 1

Views: 1597

Answers (3)

Cornel Creanga
Cornel Creanga

Reputation: 5308

At the first glance the error cause seems to be the usage of the Vector class. Are you sure that you are using an ArrayCollection and not a Vector on the flex side? Vector serialization was introduced only in BlazeDS 4.5

Upvotes: 2

Timofei Davydik
Timofei Davydik

Reputation: 7294

ArrayCollection is a very heavy class for transfering with lots of unnecessary fields. Use Array instead.

Upvotes: 0

Matt MacLean
Matt MacLean

Reputation: 19658

I am not 100% sure. But you may need to specify generics on the List.

//in FlexService.java class
public List<Car> javaFunction(String model, List<Engine> engine){
 //some code
 return carList;
}

Also be sure that all the elements in the ArrayCollection in flex have a matching java class.

Upvotes: 0

Related Questions