[英]Having SerializationException when trying to return custom object type
I just create the most simple Singleton EJB to return a custom serializable object, but I'm getting the following exception when I invoke the remote method: 我只是创建最简单的Singleton EJB以返回自定义可序列化的对象,但是在调用远程方法时遇到以下异常:
org.jboss.serial.exception.SerializationException: Could not create instance of model.Usuario - model.Usuario org.jboss.serial.exception.SerializationException:无法创建model.Usuario的实例-model.Usuario
It works fine with simple types and normal classes (String for example) but not for an object pertaining to a class I created. 它适用于简单类型和普通类(例如String),但不适用于与我创建的类有关的对象。
I'm using JBoss 6.0 and Eclipse. 我正在使用JBoss 6.0和Eclipse。
What could I be missing? 我可能会缺少什么?
Thanks in advance, Saul 预先感谢,扫罗
1.You should make your Object implementing Serializable
1.您应该使您的对象实现可
Serializable
2.Have all nonserializable fields marked as transient
. 2.将所有不可序列化的字段都标记为
transient
。
The class you are trying to serialize must implement the Serializable
marker interface or extend a class that implements it. 您要序列化的类必须实现
Serializable
标记接口或扩展实现它的类。 Also, every non-transient member of your class must also be Serializable
. 同样,您的类的每个非临时成员也必须是
Serializable
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.