protected function render(ModelAndView $mv, Request $request, Response $response)
    {
        $view = null;
        if ($mv->isReference()) {
            $view = resolveViewName($mv->getViewName(), $mv->getModelMap(), null, $request);
            if ($view == null) {
                throw new \Exception("Could not resolve view with name '".$mv->getViewName()."'.");
            }
        } else {
            $view = $mv->getView();
            if ($view == null) {
                throw new \Exception("ModelAndView neither contains a view name nor a View object.");
            }
        }
        try {
            $view->render($mv->getModelMap(), $request, $response);
        } catch (\Exception $ex) {
            $this->logger->debug("Error rendering view.");
            throw $ex;
        }
    }