Fixed class cast exception and wrong response message to client