开发者

GraniteDS can't convert from actionscript class to java bean...how to solve this?

开发者 https://www.devze.com 2023-02-17 16:20 出处:网络
I have a Entity bean and it\'s corresponding ActionScript class when i transfer an object of that class i got that error:

I have a Entity bean and it's corresponding ActionScript class when i transfer an object of that class i got that error:

13:54:07,750 ERROR [AMFMessageFilter] AMF message error
org.granite.messaging.amf.io.AMF3SerializationException
    at org.granite.messaging.amf.io.AMF3Deserializer.readObject(AMF3Deserializer.java:94)
    at org.granite.messaging.amf.io.AMF3Deserializer.readAMF3Array(AMF3Deserializer.java:261)
    at org.granite.messaging.amf.io.AMF3Deserializer.readObject(AMF3Deserializer.java:124)
    at org.granite.messaging.amf.io.AMF3Deserializer.readAMF3Object(AMF3Deserializer.java:403)
    at org.granite.messaging.amf.io.AMF3Deserializer.readObject(AMF3Deserializer.java:126)
    at org.granite.messaging.amf.io.AMF3Deserializer.readObject(AMF3Deserializer.java:88)
    at org.granite.messaging.amf.io.AMF0Deserializer.readAMF3Data(AMF0Deserializer.java:324)
    at org.granite.messaging.amf.io.AMF0Deserializer.readData(AMF0Deserializer.java:376)
    at org.granite.messaging.amf.io.AMF0Deserializer.readArray(AMF0Deserializer.java:239)
    at org.granite.messaging.amf.io.AMF0Deserializer.readData(AMF0Deserializer.java:362)
    at org.granite.messaging.amf.io.AMF0Deserializer.readBodies(AMF0Deserializer.java:155)
    at org.granite.messaging.amf.io.AMF0Deserializer.<init>(AMF0Deserializer.java:94)
    at org.granite.messaging.webapp.AMFMessageFilter.doFilter(AMFMessageFilter.java:93)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.RuntimeException: Could not read externalized object: com.xpress.spt.beans.SptPromotion@1a773bd
    at org.granite.messaging.amf.io.AMF3Deserializer.readAMF3Object(AMF3Deserializer.java:373)
    at org.granite.messaging.amf.io.AMF3Deserializer.readObject(AMF3Deserializer.java:126)
    at org.granite.messaging.amf.io.AMF3Deserializer.readObject(AMF3Deserializer.java:88)
    ... 30 more
Caused by: org.granite.messaging.amf.io.convert.NoConverterFoundException: Cannot convert: com.xpress.spt.beans.SptStatus@760dac to: java.util.Set<com.xpress.spt.beans.SptStatusHist>
    at org.granite.messaging.amf.io.convert.Converters.getConverter(Converters.java:119)
    at org.granite.messaging.amf.io.convert.Converters.convert(Converters.java:132)
    at org.granite.hibernate.HibernateExternalizer.readExternal(HibernateExternalizer.java:189)
    at org.granite.messaging.amf.io.AMF3Deserializer.readAMF3Object(AMF3Deserializer.java:369)
    ... 32 more
13:54:07,750 ERROR [[AMFMessageServlet]] Servlet.service() for servlet AMFMessageServlet threw exception
org.granite.messaging.amf.io.AMF3SerializationException
    at org.granite.messaging.amf.io.AMF3Deserializer.readObject(AMF3Deserializer.java:94)
    at org.granite.messaging.amf.io.AMF3Deserializer.readAMF3Array(AMF3Deserializer.java:261)
    at org.granite.messaging.amf.io.AMF3Deserializer.readObject(AMF3Deserializer.java:124)
    at org.granite.messaging.amf.io.AMF3Deserializer.readAMF3Object(AMF3Deserializer.java:403)
    at org.granite.messaging.amf.io.AMF3Deserializer.readObject(AMF3Deserializer.java:126)
    at org.granite.messaging.amf.io.AMF3Deserializer.readObject(AMF3Deserializer.java:88)
    at org.granite.messaging.amf.io.AMF0Deserializer.readAMF3Data(AMF0Deserializer.java:324)
    at org.granite.messaging.amf.io.AMF0Deserializer.readData(AMF0Deserializer.java:376)
    at org.granite.messaging.amf.io.AMF0Deserializer.readArray(AMF0Deserializer.java:239)
    at org.granite.messaging.amf.io.AMF0Deserializer.readData(AMF0Deserializer.java:362)
    at org.granite.messaging.amf.io.AMF0Deserializer.readBodies(AMF0Deserializer.java:155)
    at org.granite.messaging.amf.io.AMF0Deserializer.<init>(AMF0Deserializer.java:94)
    at org.granite.messaging.webapp.AMFMessageFilter.doFilter(AMFMessageFilter.java:93)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.RuntimeException: Could not read externalized object: com.xpress.spt.beans.SptPromotion@1a773bd
    at org.granite.messaging.amf.io.AMF3Deserializer.readAMF3Object(AMF3Deserializer.java:373)
    at org.granite.messaging.amf.io.AMF3Deserializer.readObject(AMF3Deserializer.java:126)
    at org.granite.messaging.amf.io.AMF3Deserializer.readObject(AMF3Deserializer.java:88)
    ... 30 more
Caused by: org.granite.messaging.amf.io.convert.NoConverterFoundException: Cannot convert: com.xpress.spt.beans.SptStatus@760dac to: java.util.Set<com.xpress.spt.beans.SptStatusHist>
    at org.granite.messaging.amf.io.convert.Converters.getConverter(Converters.java:119)
    at org.granite.messaging.amf.io.convert.Converters.convert(Converters.java:132)
    at org.granite.hibernate.HibernateExternalizer.readExternal(HibernateExternalizer.java:189)
    at org.granite.messaging.amf.io.AMF3Deserializer.readAMF3Object(AMF3Deserializer.java:369)
    ... 32 more

My java bean class:

package com.xpress.spt.beans;


import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;


/**
 * SptPromotion entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name="SPT_PROMOTION"
    ,schema="SPT_DEV"
, uniqueConstraints = {@UniqueConstraint(columnNames="LABEL"), @UniqueConstraint(columnNames="SHORT_DESCRIPTION"), @UniqueConstraint(columnNames="DESCRIPTION")}
)

public class SptPromotion  implements java.io.Serializable {


    // Fields    
    private static final long serialVersionUID = 1L;
     private Long sptCode;
     private SptMatrixRule sptMatrixRule;
     private SptStatus sptStatus;
     private SptProcess sptProcess;
     private String shortDescription;
     private String description;
     private String label;
     private Timestamp creationDate;
     private String username;
     private String bcFlag;
     private String prorationFlag;
     private String countConstraintFlag;
     private String minCommFlag;
     private Long minCommPeriod;
     private Long priority;
     private Timestamp startPromoDate;
     private Timestamp endPromoDate;
     private Timestamp lastRunDate;
     private Set<SptStatusHist> sptStatusHists = new HashSet<SptStatusHist>(0);
     private Set<SptPromotionParameter> sptPromotionParameters = new HashSet<SptPromotionParameter>(0);
     private Set<SptPromotionMechanism> sptPromotionMechanisms = new HashSet<SptPromotionMechanism>(0);
     private Set<SptCustomerPromotionHist> sptCustomerPromotionHists = new HashSet<SptCustomerPromotionHist>(0);
     private Set<SptLoadData> sptLoadDatas = new HashSet<SptLoadData>(0);
     private Set<SptDependency> sptDependenciesForSptCode = new HashSet<SptDependency>(0);
     private Set<SptDependency> sptDependenciesForDepSptCode = new HashSet<SptDependency>(0);
     private Set<SptQualifiedCustomer> sptQualifiedCustomers = new HashSet<SptQualifiedCustomer>(0);
     private Set<SptPromotionCriteria> sptPromotionCriterias = new HashSet<SptPromotionCriteria>(0);
     private Set<SptProcessLog> sptProcessLogs = new HashSet<SptProcessLog>(0);


    // Constructors

    /** default constructor */
    public SptPromotion() {
    }

    /** minimal constructor */
    public SptPromotion(Long sptCode, SptMatrixRule sptMatrixRule, SptStatus sptStatus, SptProcess sptProcess, String shortDescription, String description, String label, Timestamp creationDate, String username, String bcFlag, String prorationFlag, String countConstraintFlag, Long priority, Timestamp startPromoDate) {
        this.sptCode = sptCode;
        this.sptMatrixRule = sptMatrixRule;
        this.sptStatus = sptStatus;
        this.sptProcess = sptProcess;
        this.shortDescription = shortDescription;
        this.description = description;
        this.label = label;
        this.creationDate = creationDate;
        this.username = username;
        this.bcFlag = bcFlag;
        this.prorationFlag = prorationFlag;
        this.countConstraintFlag = countConstraintFlag;
        this.priority = priority;
        this.startPromoDate = startPromoDate;
    }

    /** full constructor */
    public SptPromotion(Long sptCode, SptMatrixRule sptMatrixRule, SptStatus sptStatus, SptProcess sptProcess, String shortDescription, String description, String label, Timestamp creationDate, String username, String bcFlag, String prorationFlag, String countConstraintFlag, String minCommFlag, Long minCommPeriod, Long priority, Timestamp startPromoDate, Timestamp endPromoDate, Timestamp lastRunDate, Set<SptStatusHist> sptStatusHists, Set<SptPromotionParameter> sptPromotionParameters, Set<SptPromotionMechanism> sptPromotionMechanisms, Set<SptCustomerPromotionHist> sptCustomerPromotionHists, Set<SptLoadData> sptLoadDatas, Set<SptDependency> sptDependenciesForSptCode, Set<SptDependency> sptDependenciesForDepSptCode, Set<SptQualifiedCustomer> sptQualifiedCustomers, Set<SptPromotionCriteria> sptPromotionCriterias, Set<SptProcessLog> sptProcessLogs) {
        this.sptCode = sptCode;
        this.sptMatrixRule = sptMatrixRule;
        this.sptStatus = sptStatus;
        this.sptProcess = sptProcess;
        this.shortDescription = shortDescription;
        this.description = description;
        this.label = label;
        this.creationDate = creationDate;
        this.username = username;
        this.bcFlag = bcFlag;
        this.prorationFlag = prorationFlag;
        this.countConstraintFlag = countConstraintFlag;
        this.minCommFlag = minCommFlag;
        this.minCommPeriod = minCommPeriod;
        this.priority = priority;
        this.startPromoDate = startPromoDate;
        this.endPromoDate = endPromoDate;
        this.lastRunDate = lastRunDate;
        this.sptStatusHists = sptStatusHists;
        this.sptPromotionParameters = sptPromotionParameters;
        this.sptPromotionMechanisms = sptPromotionMechanisms;
        this.sptCustomerPromotionHists = sptCustomerPromotionHists;
        this.sptLoadDatas = sptLoadDatas;
        this.sptDependenciesForSptCode = sptDependenciesForSptCode;
        this.sptDependenciesForDepSptCode = sptDependenciesForDepSptCode;
        this.sptQualifiedCustomers = sptQualifiedCustomers;
        this.sptPromotionCriterias = sptPromotionCriterias;
        this.sptProcessLogs = sptProcessLogs;
    }


    // Property accessors omitted
    //.............

}

and here its corresponding ActionScript class generated by Gas3 code generation tool:

/**
 * Generated by Gas3 v2.1.0 (Granite Data Services).
 *
 * WARNING: DO NOT CHANGE THIS FILE. IT MAY BE OVERWRITTEN EACH TIME YOU USE
 * THE GENERATOR. INSTEAD, EDIT THE INHERITED CLASS (SptPromotion.as).
 */

package com.xpress.spt.beans {

    import flash.utils.IDataInput;
    import flash.utils.IDataOutput;
    import flash.utils.IExternalizable;
    import mx.collections.ListCollectionView;
    import org.granite.collections.IPersistentCollection;
    import org.granite.meta;

    use namespace meta;

    [Bindable]
    public class SptPromotionBase implements IExternalizable {

        private var __initialized:Boolean = true;
        private var __detachedState:String = null;

        private var _bcFlag:String;
        private var _countConstraintFlag:String;
        private var _creationDate:Date;
        private var _description:String;
        private var _endPromoDate:Date;
        private var _label:String;
        private var _lastRunDate:Date;
        private var _minCommFlag:String;
        private var _minCommPeriod:Number;
        private var _priority:Number;
        private var _prorationFlag:String;
        private var _shortDescription:String;
        private var _sptCode:Number;
        private var _sptCustomerPromotionHists:ListCollectionView;
        private var _sptDependenciesForDepSptCode:ListCollectionView;
        private var _sptDependenciesForSptCode:ListCollectionView;
        private var _sptLoadDatas:ListCollectionView;
        private var _sptMatrixRule:SptMatrixRule;
        private var _sptProcess:SptProcess;
        private var _sptProcessLogs:ListCollectionView;
        private var _sptPromotionCriterias:ListCollectionView;
        private var _sptPromotionMechanisms:ListCollectionView;
        private var _sptPromotionParameters:ListCollectionView;
        private var _sptQualifiedCustomers:ListCollectionView;
        private var _sptStatus:SptStatus;
        private var _sptStatusHists:ListCollectionView;
        private var _startPromoDate:Date;
        private var _username:String;

        meta function isInitialized(name:String = null):Boolean {
            if (!name)
                return __initialized;

            var property:* = this[name];
            return (
                (!(property is SptPromotion) || (property as SptPromotion).meta::isInitialized()) &&
                (!(property is IPersistentCollection) || (property as IPersistentCollection).isInitialized())
            );
        }

        //setters and getters omitted
        //...........

        public function readExternal(input:IDataInput):void {
            __initialized = input.readObject() as Boolean;
            __detachedState = input.readObject() as String;
            if (meta::isInitialized()) {
                _bcFlag = input.readObject() as String;
                _countConstraintFlag = input.readObject() as String;
                _creationDate = input.readObject() as Date;
                _description = input.readObject() as String;
                _endPromoDate = input.readObject() as Date;
                _label = input.readObject() as String;
                _lastRunDate = input.readObject() as Date;
                _minCommFlag = input.readObject() as String;
                _minCommPeriod = function(o:*):Number { return (o is Number ? o as Number : Number.NaN) } (input.readObject());
                _priority = function(o:*):Number { return (o is Number ? o as Number : Number.NaN) } (input.readObject());
                _prorationFlag = input.readObject() as String;
                _shortDescription = input.readObject() as String;
                _sptCode = function(o:*):Number { return (o is Number ? o as Number : Number.NaN) } (input.readObject());
                _sptCustomerPromotionHists = input.readObject() as ListCollectionView;
                _sptDependenciesForDepSptCode = input.readObject() as ListCollectionView;
                _sptDependenciesForSptCode = input.readObject() as ListCollectionView;
                _sptLoadDatas = input.readObject() as ListCollectionView;
                _sptMatrixRule = input.readObject() as SptMatrixRule;
                _sptProcess = input.readObject() as SptProcess;
                _sptProcessLogs = input.readObject() as ListCollectionView;
                _sptPromotionCriterias = input.readObject() as ListCollectionView;
                _sptPromotionMechanisms = input.readObject() as ListCollectionView;
                _sptPromotionParameters = input.readObject() as ListCollectionView;
                _sptQualifiedCustomers = input.readObject() as ListCollectionView;
                _sptStatus = input.readObject() as SptStatus;
                _sptStatusHists = input.readObject() as ListCollectionView;
                _startPromoDate = input.readObject() as Date;
                _username = input.readObject() as String;
            }
            else {
                _sptCode = function(o:*):Number { return (o is Number ? o as Number : Number.NaN) } (input.readObject());
            }
        }

        public function writeExternal(output:IDataOutput):void {
            output.writeObject(__initialized);
            output.writeObject(__detache开发者_JAVA百科dState);
            if (meta::isInitialized()) {
                output.writeObject(_bcFlag);
                output.writeObject(_countConstraintFlag);
                output.writeObject(_creationDate);
                output.writeObject(_description);
                output.writeObject(_endPromoDate);
                output.writeObject(_label);
                output.writeObject(_lastRunDate);
                output.writeObject(_minCommFlag);
                output.writeObject(_minCommPeriod);
                output.writeObject(_priority);
                output.writeObject(_prorationFlag);
                output.writeObject(_shortDescription);
                output.writeObject(_sptCode);
                output.writeObject(_sptCustomerPromotionHists);
                output.writeObject(_sptDependenciesForDepSptCode);
                output.writeObject(_sptDependenciesForSptCode);
                output.writeObject(_sptLoadDatas);
                output.writeObject(_sptMatrixRule);
                output.writeObject(_sptProcess);
                output.writeObject(_sptProcessLogs);
                output.writeObject(_sptPromotionCriterias);
                output.writeObject(_sptPromotionMechanisms);
                output.writeObject(_sptPromotionParameters);
                output.writeObject(_sptQualifiedCustomers);
                output.writeObject(_sptStatus);
                output.writeObject(_sptStatusHists);
                output.writeObject(_startPromoDate);
                output.writeObject(_username);
            }
            else {
                output.writeObject(_sptCode);
            }
        }
    }
}

please any help ??? thanks in advance :)


I had a problem like that. In my case, it happen when using Modules.

So I needed to pre load the specific class in my main application.

On Main.mxml:

private var loadClasses:Array = [Funcionario, Cliente, Projeto];


From your exception ...

Caused by: org.granite.messaging.amf.io.convert.NoConverterFoundException:
Cannot convert: com.xpress.spt.beans.SptStatus@760dac
to: java.util.Set<com.xpress.spt.beans.SptStatusHist>

... I would guess you have a type conflict between SptStatus and Set<SptStatusHist>.


We had that problem too with enums. Solved by a recent upgrade of Granite. It depends where you did put the granite jars. If in jboss/server/default/lib you may have this error. If granite.jar inside your project should not occur. anyway do an fresh update of granite jars...

0

精彩评论

暂无评论...
验证码 换一张
取 消