博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
springmvc Could not write content: No serializer
阅读量:6293 次
发布时间:2019-06-22

本文共 1897 字,大约阅读时间需要 6 分钟。

  hot3.png

HTTP Status 500 - Could not write content: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.pbc.rsms.entity.UserInfo_$$_jvstcc6_0["handler"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.pbc.rsms.entity.UserInfo_$$_jvstcc6_0["handler"])

 

 原因:

The problem is that with load method you get just a proxy but not the real object. The proxy object doesn't have the properties already loaded so when the serialization happens there are no properties to be serialized. With the get method you actually get the real object, this object could in fact be serialized.

解决办法1:

在hibernate生成的实体类中加:

@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})

解决办法2:

load变get

I think that the problem is the way that you retrieve the entity.

Maybe you are doing something like this:

Person p = (Person) session.load(Person.class, new Integer(id));

Try using the method get instead of load

Person p = (Person) session.get(Person.class, new Integer(id));

The problem is that with load method you get just a proxy but not the real object. The proxy object doesn't have the properties already loaded so when the serialization happens there are no properties to be serialized. With the get method you actually get the real object, this object could in fact be serialized.

 

解决办法来源:http://stackoverflow.com/questions/24994440/no-serializer-found-for-class-org-hibernate-proxy-pojo-javassist-javassist

转载于:https://my.oschina.net/lieefu/blog/680098

你可能感兴趣的文章
在SDN走向商用部署的路上,锐捷网络一直在不断实践
查看>>
微信做入口,微软却想做入口的入口
查看>>
你知道数据中心宕机的真正成本吗?
查看>>
「雷锋前线」那昕出任CEO,“什么值得买”会变吗
查看>>
如何构建高可用ZooKeeper集群
查看>>
NodeJS和C++之间的类型转换
查看>>
你的代码糟粕比精华要多得多
查看>>
混合云是企业IT的未来吗?
查看>>
Salesforce针对移动工作人员推全新人工智能支持工具
查看>>
《深入理解Nginx:模块开发与架构解析》一1.2 为什么选择Nginx
查看>>
IDC:企业向云转变推动了SD-WAN市场增长
查看>>
《深入理解C++11:C++ 11新特性解析与应用》——2.4 宏__cplusplus
查看>>
苹果发行10亿美元绿色债券 继续支持巴黎协定
查看>>
杨彪 | 一次线上游戏卡死的解决历程(文末赠书福利)
查看>>
最新蓝牙版本助力实现“无连接式” 物联网
查看>>
企业该如何选择WMS系统?
查看>>
《MongoDB管理与开发精要》——1.4节本章小结
查看>>
美国防部报告传指联想产品带来网络威胁
查看>>
php实现查询功能
查看>>
IBM拓展云数据分析服务 用户来“做主”
查看>>