Announcement Announcement Module
Collapse
No announcement yet.
Cannot convert value of type [flex.messaging.io.amf.ASObject] to required type Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cannot convert value of type [flex.messaging.io.amf.ASObject] to required type

    Hi,
    Thanks for your coming here.
    I have encountered a error when I use Spring BlazeDS Integration(version 1.5.0.M1).

    I have two java beans as below:

    Code:
    public class UserFilter{
            private Long userFilterOid;
    	private Employee employee;
    	private String name;
    	private int sort;
    	private String module;
    	private boolean isAll;
    	private Set<UserSearchCriteria> userSearchCriterias; 
            //set get method......
    }
    Code:
    public class UserSearchCriteria{
            private Long userSearchCriteriaOid;
    	private UserFilter userFilter;
    	private String fieldName;
    	private String searchCondition;
    	private String fieldValue; 
            //set get method......
    }
    two actionscript beans as below:

    Code:
    package com.kaidi.eas.model
    {
    
      import com.kaidi.eas.model.Employee;
      import com.kaidi.eas.model.UserSearchCriteria;
    
      [Bindable]
      [RemoteClass(alias="com.kaidi.eas.model.UserSearchCriteria")]
    
      public class UserSearchCriteria
      {
        public var userSearchCriteriaOid:Number;
        public var employee:Employee;
        public var fieldName:String;
        public var searchCondition:String;
        public var fieldValue:String;
        public var oid:Number;
      }
    }
    Code:
    package com.kaidi.eas.model
    {
      import com.kaidi.eas.model.Employee;
      import com.kaidi.eas.model.UserFilter;
      import mx.collections.ArrayCollection;
    
      [Bindable]
      [RemoteClass(alias="com.kaidi.eas.model.UserFilter")]
      public class UserFilter
      {
        public var userFilterOid:Number;
        public var employee:Employee;
        public var name:String;
        public var sort:String;
        public var module:String;
        public var isAll:Boolean;
        public var userSearchCriterias : ArrayCollection;
        public var oid:Number;
      }
    }

    I am using hibernate HQL to fetch a list:

    List<UserFilter> filterList = userFilterDao.getFilters(userOid, moduleName);


    the userFilterDao->getFilters code as below:

    Code:
    public List<UserFilter> getFilters(long userOid, String module) {
    		final String queryString = "from UserFilter filter "
    			+ " left join fetch filter.userSearchCriterias "
    			+ " left join fetch filter.employee empl "
    			+ " where empl.employeeOid = :userOid "
    			+ " and filter.module = :module "
    			+ " order by filter.sort "
    			;
    		String[] paramNames = { "userOid", "module" };
    		Object[] parameters = { userOid, module };
    		List<UserFilter> list = this.getHibernateTemplate().findByNamedParam(queryString, paramNames, parameters);
    		return list;
    }

    the filterList will pass to the flex side.but the UserSearchCriteria in filterList items will not serialize success. just show as Object type but I can get the values in this Object. The application works well.

    But when I pass an UserFilter(filterList.getItemAt(0)) back to the java side. the sever will throw exception as below:

    Code:
    [BlazeDS]Error deserializing client message.
    org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'flex.messaging.io.ArrayCollection' to required type 'java.util.Set' for property 'userSearchCriterias'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [flex.messaging.io.amf.ASObject] to required type [com.kaidi.eas.model.UserSearchCriteria] for property 'userSearchCriterias[0]': no matching editors or conversion strategy found
    	at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:462)
    	at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:499)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1071)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:876)
    	at org.springframework.flex.core.io.SpringPropertyProxy.setValue(SpringPropertyProxy.java:98)
    	at flex.messaging.io.amf.Amf3Input.readScriptObject(Amf3Input.java:438)
    	at flex.messaging.io.amf.Amf3Input.readObjectValue(Amf3Input.java:152)
    	at flex.messaging.io.amf.Amf3Input.readObject(Amf3Input.java:130)
    	at flex.messaging.io.amf.Amf3Input.readArray(Amf3Input.java:358)
    	at flex.messaging.io.amf.Amf3Input.readObjectValue(Amf3Input.java:156)
    	at flex.messaging.io.amf.Amf3Input.readObject(Amf3Input.java:130)
    	at flex.messaging.io.amf.Amf3Input.readScriptObject(Amf3Input.java:437)
    	at flex.messaging.io.amf.Amf3Input.readObjectValue(Amf3Input.java:152)
    	at flex.messaging.io.amf.Amf3Input.readObject(Amf3Input.java:130)
    	at flex.messaging.io.amf.Amf0Input.readObjectValue(Amf0Input.java:123)
    	at flex.messaging.io.amf.Amf0Input.readArrayValue(Amf0Input.java:359)
    	at flex.messaging.io.amf.Amf0Input.readObjectValue(Amf0Input.java:127)
    	at flex.messaging.io.amf.Amf0Input.readObject(Amf0Input.java:94)
    	at flex.messaging.io.amf.AmfMessageDeserializer.readObject(AmfMessageDeserializer.java:227)
    	at flex.messaging.io.amf.AmfMessageDeserializer.readBody(AmfMessageDeserializer.java:206)
    	at flex.messaging.io.amf.AmfMessageDeserializer.readMessage(AmfMessageDeserializer.java:126)
    	at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:145)
    	at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:291)
    	at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$4b5262f7.service(<generated>)
    	at org.springframework.flex.servlet.MessageBrokerHandlerAdapter.handle(MessageBrokerHandlerAdapter.java:108)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:774)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    	at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.IllegalStateException: Cannot convert value of type [flex.messaging.io.amf.ASObject] to required type [com.kaidi.eas.model.UserSearchCriteria] for property 'userSearchCriterias[0]': no matching editors or conversion strategy found
    	at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
    	at org.springframework.beans.TypeConverterDelegate.convertToTypedCollection(TypeConverterDelegate.java:520)
    	at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:173)
    	at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:447)
    	... 42 more
    the flex log show as below:
    Code:
    [RPC Fault faultString="Error deserializing client message." faultCode="Client.Packet.Encoding" faultDetail="null"]
    	at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:345]
    	at mx.rpc::Responder/fault()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:68]
    	at mx.rpc::AsyncRequest/fault()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:113]
    	at NetConnectionMessageResponder/statusHandler()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:609]
    	at mx.messaging::MessageResponder/status()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:264]

    Do you have any good suggestions to fix it?
    Thank you.
    Last edited by kevintech; Nov 30th, 2010, 06:00 PM. Reason: use code tage and provide as beans

  • #2
    Can you provide the code of your ActionScript objects as well to show how they map to the Java objects?

    Also, please use the code tags instead of bold, as it makes it much easier to read.

    Comment


    • #3
      I have found the cause of the issue,
      one more flied in the as object:

      Code:
      public var oid:Number;
      in the same time, I found that a java.until.set

      Code:
      public var userSearchCriterias : ArrayCollection;
      can't be Serialize to as. Just turn to an object.
      Last edited by kevintech; Dec 1st, 2010, 04:57 PM.

      Comment


      • #4
        Problem fixed

        Becuase I didn't declare the UserSearchCriteria in the as class. and the SDK compiler didn't know the class UserSearchCriteria .

        So I added the code
        Code:
        Code:
        public var userSearchCriteria : UserSearchCriteria ;
        and import the class UserSearchCriteria. problem fixed!

        Comment

        Working...
        X