This kind of java.lang.IllegalStateException exception are triggered when some Java code is executed after a forward(), sendRedirect() or sendError().
You can refer to this StackOverflow thread to learn more about how to avoid this in Java: here

I’ve encountered this error in ADF a couple of time when you use a forward(), sendRedirect() or sendError() in a JSF action even if you do add the return; as ADF execute its own java code at the end of an action.

To avoid this you have to keep the business logic inside the action handler and move the forward(), sendRedirect() or sendError() inside the ActionEventListener operation.

Example :