Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java GAE不尊重泽西';s WebApplicationException_Java_Google App Engine_Jersey - Fatal编程技术网

Java GAE不尊重泽西';s WebApplicationException

Java GAE不尊重泽西';s WebApplicationException,java,google-app-engine,jersey,Java,Google App Engine,Jersey,我的资源: public class NotAuthorizedException extends WebApplicationException { public NotAuthorizedException(String message) { super(Response.status(Response.Status.BAD_REQUEST).entity(message).type(MediaType.TEXT_PLAIN).build()); } }

我的资源:

public class NotAuthorizedException extends WebApplicationException {
    public NotAuthorizedException(String message) {
           super(Response.status(Response.Status.BAD_REQUEST).entity(message).type(MediaType.TEXT_PLAIN).build());
    }
}
在GAE dev server中,我的客户端接收到
我的异常
,这是我所期望的,但在生产模式下,它返回:

public class MyResource{
@GET
public Book getBook(){
   ...
   throw new NotAuthorizedException("my exception");
}
}

400错误请求
错误:请求错误
这似乎是GAE默认的400错误响应


提前感谢。

我遇到了类似的问题。您的问题可以通过将“jersey.config.server.response.setStatusOverSendError”设置为true来解决。有关详细信息,请参见。

此问题已由@Takahiko Kawasaki回答,但为了完整起见,以下是设置上述Jersey属性的两种可选方法:

以编程方式:

<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>400 Bad Request</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Bad Request</h1>
</body></html>
或在web.xml中:

new ResourceConfig()
       .property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, true);

美国石油学会
org.glassfish.jersey.servlet.ServletContainer
....
jersey.config.server.response.setStatusOversender错误
真的
<servlet>
  <servlet-name>API</servlet-name>
  <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
  ....
  <init-param>
    <param-name>jersey.config.server.response.setStatusOverSendError</param-name>
    <param-value>true</param-value>
  </init-param>
</servlet>