onEndRequest() is a method of CApplication, not CComponent… Putting onEndRequest() in a component won’t do anything. Unless you mean you are calling the component in onEndRequest(). How is the component called?
yes I tried using getController and i registered component method as onendrequest handler. If you look in the code it resets app controller back to $oldcontroller, but $oldcontroller is NULL. why is this swap necessary?
The swap I believe your talking about is required in the cases where a component is used, and the controller needs to be the current controller. OnEndRequest there is no active controller so you should get null.
You probably want to override YiiApp:afterControllerAction()