简体   繁体   English

尝试返回自定义对象类型时出现SerializationException

[英]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.

相关问题 尝试返回上一个 JFrame 时遇到困难 - Having difficulty when trying to return to previous JFrame GWT-发送Map时出现SerializationException <Object, Object> - GWT - SerializationException when I send Map<Object, Object> @ControllerAdvice Spring - 返回类型作为自定义对象而不是ModelAndView - @ControllerAdvice Spring - Return type as a custom object and not ModelAndView 尝试传递自定义 oracle 类型对象映射时无效的名称模式 - invalid name pattern when trying to pass custom oracle type object mapping 与Java中的方法的返回类型和输入参数具有相同的对象 - having the same object as return type and input argument for a method in Java 当Object是Java方法中的返回类型时,返回特定类型 - return a specific type when Object is the return type in a method in Java GWT-带有类对象的RPC SerializationException - GWT - RPC SerializationException with class object 尝试返回自定义类对象时出现AIDL错误 - AIDL ERROR while trying to return custom class object 了解何时使用Object作为返回类型 - Understanding when to use Object as return type JAva:如何将自定义对象类型作为参数传递给方法,并返回相同的自定义对象类型值 - JAva:How to pass a custom object type as a parameter to a method and return the same custom object type value back
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM