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: java.util.ArrayList[0]->com.agen.entity.User["positionchanges"]->org.hibernate.collection.internal.PersistentSet[0]->com.agen.entity.Positionchange["position"]->com.agen.entity.Position_$$_jvst714_7["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: java.util.ArrayList[0]->com.agen.entity.User["positionchanges"]->org.hibernate.collection.internal.PersistentSet[0]->com.agen.entity.Positionchange["position"]->com.agen.entity.Position_$$_jvst714_7["handler"])

解决方式:

1.可以将报错位置的

修改为

这是一种解决方式!

2.网友解决方法

hibernate会给每个被管理的对象加上hibernateLazyInitializer属性,同时struts-jsonplugin或者其他的jsonplugin都是

因为jsonplugin用的是java的内审机制.hibernate会给被管理的pojo加入一个hibernateLazyInitializer属性,jsonplugin通过java的反射机制将pojo转换成json,会把hibernateLazyInitializer也拿出来操作,但是hibernateLazyInitializer无法由反射得到,所以就抛异常了。

所以在我的pojo类上加上如下声明:

@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})

@JsonIgnoreProperties(value={"hibernateLazyInitializer"})   (此时只是忽略hibernateLazyInitializer属性)要加载被lazy的,也就是many-to-one的one端的pojo上

这行代码的作用在于告诉你的jsonplug组件,在将你的代理对象转换为json对象时,忽略value对应的数组中的属性,即:

通过java的反射机制将pojo转换成json的,属性,(通过java的反射机制将pojo转换成json的,)

"hibernateLazyInitializer","handler","fieldHandler",(如果你想在转换的时候继续忽略其他属性,可以在数组中继续加入)

【实体 报错 】No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer的更多相关文章

  1. No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer

    异常信息如下所示: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for cla ...

  2. 【hibernate 报错】No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer 【get和load的区别】

    报错: HTTP Status 500 - Could not write content: No serializer found for class org.hibernate.proxy.poj ...

  3. No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer解决方法

    org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.hibernate.proxy.poj ...

  4. 异常处理:No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer

    No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no pro ...

  5. org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.

    2011-08-16 13:26:58,484 [http-8080-1] ERROR [core.web.ExceptionInterceptor] - org.codehaus.jackson.m ...

  6. Could not write content: No serializer found for class and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) )

    1. 问题 org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: N ...

  7. No serializer found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor

    使用jpa做增删改查的时候出现了这个异常,原因是转化成json的时候,fasterxml.jackson将对象转换为json报错,发现有字段为null 解决方案:实体类上添加 @JsonIgnoreP ...

  8. Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.apache.catalina.connector.CoyoteWriter and no properties discovered to create BeanSerializer

    一.什么是序列化In computer science, in the context of data storage, serialization is the process of transla ...

  9. No serializer found for class com.bean.user and no properties discovered to create BeanSerializer

    解决方法: 方法1:将bean目录下的实体类属性由private改为public(不推荐): 方法2:给实体类属性设置setter和getter方法(推荐使用).

随机推荐

  1. 终止函数 atexit()

    函数名: atexit   头文件:#include<stdlib.h>   功 能: 注册终止函数(即main执行结束后调用的函数)   用 法: int atexit(void (*f ...

  2. linux---centos7 安装chromedriver

    1.安装浏览器 指定yum 源 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.re ...

  3. 洛谷P1339 [USACO09OCT]热浪Heat Wave 题解

    题目传送门 这道题实际非常简单好奇是怎么变黄的... 其实也就是一个SPFA,本人非常懒,不想打邻接表,直接用矩阵就好啦... #include<bits/stdc++.h> using ...

  4. day5冒泡排序

    冒泡排序:是一种基础的算法,实现数据的排序,排序的原则是前一个与后一个进行比较,如果前面的值大则交换,否则不交换,多次循环每次把最大的数据循环至后面就能够完成所需. 上面的图是冒泡排序的原理,每次循环 ...

  5. 【leetcode】 21. Merge Two Sorted Lists

    题目描述: Merge two sorted linked lists and return it as a new list. The new list should be made by spli ...

  6. MYSQL注入天书之前言

    写在前面的一些内容 请允许我叨叨一顿: 最初看到sqli-labs也是好几年之前了,那时候玩了前面的几个关卡,就没有继续下去了.最近因某个需求想起了sqli-labs,所以翻出来玩了下.从每一关卡的娱 ...

  7. Xamarin Android权限请求

    Xamarin Android权限请求   Android权限规定了App是否可以访问特定的资源,如网络.电话和短信.在原有API 6.0之前,App在安全的时候,会请求一次权限.一旦安装后,App就 ...

  8. 一个简单的ConnectionPool,手动搞

    看了一圈, 没看到稍微好用的ConnectionPool, 除了一个aiomysql, 但是这个是异步的, 我暂时没有用到这么高版本的Python, 所以就动手造一个轮子. 原理比较简单, 先造一个线 ...

  9. 【BZOJ 4555】 4555: [Tjoi2016&Heoi2016]求和 (NTT)

    4555: [Tjoi2016&Heoi2016]求和 Time Limit: 40 Sec  Memory Limit: 128 MBSubmit: 315  Solved: 252 Des ...

  10. android 同一个service启动之后 能不能被绑定bind

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha 可以 startService 启动了一个服务,这个服务可以再调用 bindServic ...