2014-09-22 134 views
0

将as3对象反序列化为java时。 GraniteDS抛出这个Exeption:错误反序列化graniteds amf对象

java.lang.ClassNotFoundException: org.hibernate.collection.PersistentSet 

我认为一些依赖项应该在pom.xml中。有任何想法吗 ?

回答

0

GraniteDS在序列化/反序列化时,除了原始类型和集合外,并不知道有关hibernate /任何pojos的任何信息。所以,就你的情况而言,即使图书馆已经到位org.hibernate.collection.PersistentSet花岗岩并不寻找它。

解决方案:

使用INT GraniteDS的创建休眠对象的副本,让你 将有一个版本用于发送AMF对象和另一个 处理休眠。此外,有两个 副本是一个好习惯。

+0

对不起,我不明白你的建议。通过创建不同的副本,你的意思是什么? – 2014-09-22 22:10:11

+0

@SamiJmii含义,请勿使用hibernate对象将数据发送到UI。如果在Hibernate中有Person对象,则在另一个包中创建另一个名为Person的对象,但具有相同的属性,并使用此对象发送到UI。 – Zeus 2014-09-22 23:04:40

+0

好的,但是当我从flex客户端发送数据到服务器时发生这种throwble(类未找到)。它在将我的'人员'数据反序列化为相应的java类型时会以某种方式发生。我的个人数据甚至没有任何收集数据只是原始类型。 – 2014-09-22 23:16:22

0

调试后,这似乎GraniteDS的(版本:3.1.0.GA)提出了这个类作为externalizer

org.granite.hibernate.HibernateExternalizer 

至极依赖于Hibernate依赖:

import org.hibernate.collection.PersistentCollection; 
import org.hibernate.collection.PersistentList; 
import org.hibernate.collection.PersistentMap; 
import org.hibernate.collection.PersistentSet; 
import org.hibernate.collection.PersistentSortedMap; 
import org.hibernate.collection.PersistentSortedSet; 

这些依赖都OK在休眠版本(3.X)。但是包命名空间不再的Valide休眠4:

import org.hibernate.collection.internal.PersistentBag; 
import org.hibernate.collection.internal.PersistentList; 
import org.hibernate.collection.internal.PersistentMap; 
import org.hibernate.collection.internal.PersistentSet; 
import org.hibernate.collection.internal.PersistentSortedMap; 
import org.hibernate.collection.internal.PersistentSortedSet; 

的解决方法:我们可以定义我们的欧文externalizer具有相同的实现HibernateExternalizer,改变进口。那么我们在granite-config.xml中使用这个自定义外部化器。

希望graniteDS可以从外部依赖关系中解耦出来,这可能会导致重大更改,如下所示。