use of com.haulmont.cuba.core.sys.serialization.SerializationException in project cuba by cuba-platform.
the class HttpServiceExporter method handleRequest.
/*
* In base implementation, exceptions which are thrown during reading remote invocation request, are not handled.
* Client gets useless HTTP status 500 in this case.
*
* This implementation passes some known exceptions to client.
*/
@Override
public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (!ServiceExportHelper.exposeServices()) {
logger.debug("Services are not exposed due to 'cuba.doNotExposeRemoteServices' is set to true");
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
RemoteInvocationResult result;
RemoteInvocation invocation = null;
try {
invocation = readRemoteInvocation(request);
result = invokeAndCreateResult(invocation, getProxy());
} catch (OptionalDataException | ClassCastException e) {
// typical binary incompatibility exceptions
logger.error("Failed to read remote invocation request", e);
result = new RemoteInvocationResult(e);
} catch (ClassNotFoundException ex) {
throw new NestedServletException("Class not found during deserialization", ex);
}
try {
writeRemoteInvocationResult(request, response, result);
} catch (SerializationException e) {
String serviceName = null;
if (getServiceInterface() != null) {
serviceName = getServiceInterface().getSimpleName();
}
String methodName = null;
String paramTypes = null;
if (invocation != null) {
methodName = invocation.getMethodName();
if (invocation.getParameterTypes() != null) {
paramTypes = Joiner.on(",").join(invocation.getParameterTypes());
}
}
throw new NestedServletException(String.format("Failed to write result for service [%s.%s(%s)]", serviceName, methodName, paramTypes), e);
}
}
Aggregations