将 Resteasy 与 javassist 一起使用?
我正在尝试使用 Resteasy 来提供 spring-hibernate 获取的一些实体。
我配置了一种返回 POJO 并按预期工作的方法:
@GET
@Path("/test")
@Produces(MediaType.APPLICATION_XML)
public Episode getTestEpisode() {
Episode e = new Episode();
e.setEpisodename("test");
return e;
}
Produces:
<episode episodeId="0">
<combinedEpisodenumber>0.0</combinedEpisodenumber>
<combinedSeason>0</combinedSeason>
<episodename>test</episodename>
<episodenumber>0</episodenumber>
<seasonId>0</seasonId>
<seasonnumber>0</seasonnumber>
</episode>
但是,如果我尝试从 spring/hibernate 返回某些内容,则会收到错误:
无法找到类型为 com.company.domain.Episode_$$_javassist_27 媒体类型为 application/xml 的响应对象的 MessageBodyWriter
我想这对 javassist 来说是一种魔力,但是我认为它不是预期的类,这让 JAX-B 感到困惑。我可以告诉 JAX-B 在哪里查找注释,或者我可以从该对象获取 POJO 吗?
从未直接使用过javassist,所以不确定它是如何工作的。
I'm trying to use resteasy to serve out some entities fetched by spring-hibernate.
I've configured one method which returns a POJO and works as expected:
@GET
@Path("/test")
@Produces(MediaType.APPLICATION_XML)
public Episode getTestEpisode() {
Episode e = new Episode();
e.setEpisodename("test");
return e;
}
Produces:
<episode episodeId="0">
<combinedEpisodenumber>0.0</combinedEpisodenumber>
<combinedSeason>0</combinedSeason>
<episodename>test</episodename>
<episodenumber>0</episodenumber>
<seasonId>0</seasonId>
<seasonnumber>0</seasonnumber>
</episode>
However, if I try and return something from spring/hibernate I get an error:
Could not find MessageBodyWriter for response object of type: com.company.domain.Episode_$$_javassist_27 of media type: application/xml
I imagine this is some magic with javassist, however I think it's confusing JAX-B by not being the expected class. Can I tell JAX-B where to look for the annotations, or can I get a POJO from this object?
Never used javassist directly, so not sure how it works.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须对对象进行去代理..找到一个有效的实用方法..
转换 Hibernate真实对象的代理
}
You have to de-proxy the object.. found a utility method that works..
Converting Hibernate proxy to real object
}