It seems that layout page is not loaded, but only view is rendered.
Try to check Controller.php if in some place you set $layout globally.
In addition, i’ll try to make (if you haven’t done) a new action with only throw exception. So you can check that the problem is in that specific action and not in all Controller.php.
The problem is, that you execute the exception twice, because your actionError seems to be a method of the same controller where you throw the exception on beforeAction.
So on handling/rendering the error action the exception will be thrown a second time.
In beforeAction you have to
add param action (compatible with the parent)
exclude the error action from the exception
return true to handle the action
protected function beforeAction($action)
{
if($action->id != 'error')
throw new CHttpException(404,'message');
return true;
}
Another solution is to create an extra error-controller with the actionError, not throwing an exception in beforeAction() or init().
This is the reason why your code is working in a subcontroller correctly, because the actionError is not a method of this controller.