简体   繁体   English

Dropwizard序列化对JSON答案的异常

[英]Dropwizard exception on serializing answer to json

I've configured ExceptionMapper for java.lang.Exception . 我已经为java.lang.Exception配置了ExceptionMapper So any app exception should be processed by this mapper (I thought). 因此,任何应用程序异常都应由此映射器处理(我认为)。

For some requests I got 500 (Server Error) response with following content: 对于某些请求,我收到500 (Server Error)响应,内容如下:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 500 Server Error</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /actresses. Reason:
<pre>    Server Error</pre></p><br/>                                                
<br/>      

I checked logs - empty! 我检查了日志-空的! I've got following log settings 我有以下日志设置

logging:
  level: INFO  

After changing log level to DEBUG dropwizard printed org.hibernate.LazyInitializationException - on serializing answer hibernate throws an exception. 将日志级别更改为DEBUG dropwizard打印org.hibernate.LazyInitializationException在序列化答案时,hibernate引发异常。

Pls answer following questions: 请回答以下问题:

  1. Why does dropwizard not prints this exception with INFO level? 为什么dropwizard不以INFO级别显示此异常?
  2. Why does dropwizard not process this exception by my ExceptionMapper ? 为什么dropwizard无法通过ExceptionMapper处理此ExceptionMapper
  3. Why does dropwizard return HTML for Accept: application/json request? 为什么dropwizard返回HTML以Accept: application/json请求?

I think this is related to using DropWizard 0.6 with Java 7. We found the same issue. 我认为这与在Java 7中使用DropWizard 0.6有关。我们发现了相同的问题。 Upgrading to DW 7, or running with Java 6 should fix it. 升级到DW 7或与Java 6一起运行应该可以解决该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM