I have a JAX-WS web service with a web method that can throw an exception.
@WebMethod
public Folder getTree() throws UnauthorizedException {
if (!authorized) {
throw new UnauthorizedException();
}
}
It works correctly if the user is authorized, but when an exception is thrown, it does not generate a SOAP message with an error, it just resets the web service using
SEVERE: Unauthorized
ru.cos.xdoc.storage.UnauthorizedException: Unauthorized
at ru.cos.xdoc.storage.Storage.getTree(Storage.java:136)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
and closes the connection
HTTP/1.1 500 Internal Server Error
X-Powered-By: Servlet/2.5
Server: Sun GlassFish Enterprise Server v2.1.1
Content-Type: text/xml;charset="utf-8"
Transfer-Encoding: chunked
Date: Mon, 20 Sep 2010 15:43:59 GMT
Connection: close
It seems to me that I missed something simple
EDIT The problem only occurs if an exception is raised soon after the start of the web method. When a delay is introduced before throwing exceptions, for example
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
throw new UnauthorizedException();
everything is working fine.
Does anyone know what might cause such strange behavior?
source
share