Another entities-cannot-be-cast-to-javassist-util-proxy-proxy

徘徊边缘 提交于 2019-12-01 18:11:22
cuilei103

I encountered the same error and the strange thing is that all the other entities in my project run ok, except one. According to Boris the Spider's suggestion, I checked my project and found that there is a jar called weld-osgi-bundle.jar(in theJava EE 6 Libraries, provided by myEclipse10.0) contains some javassist code which may be conflict with javassist-3.18.1-GA.jarin my web libraries. So I removed it, and the problem gets solved.

I also hit this issue while attempting to render an entity as JSON using Spring's @ResponseBody annotation. The issue turned out to be a relationship annotated as @ManyToOne with a FetchType of LAZY. The error message was not at all helpful. Switching to EAGER fetch solved the problem.

It may be helpful to note that in my case, the target entity also had a relationship of @ManyToOne which was recursive (target table had a foreign key to itself) which was also mapped as LAZY. Both relationships had to be switched to EAGER to get the problem resolved.

So I ran into this issue, and I thought I would add some additional details for those who might have the same problem.

I had a collection of dependencies, and one imported org.javassist:javassist:3.18.1-GA, while the other imported javassist:javassist:3.11.0.GA.

Because of the different groups (it would seem that javassist:javassist became org.javassist:javassist), the build tool wasn't excluding one in favour of the other, and my WAR file had both.

I had to manually exclude the old javassist dependency, and once it was removed everything was fine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!