Issue
- When this error "java.lang.IllegalStateException: UT010006: Cannot call getWriter(), getOutputStream() already called" occurs?
2021-10-04 09:09:58.095 ERROR [default task-34][IncludeTag:128] Current URL / generates exception: java.lang.IllegalStateException: UT010006: Cannot call getWriter(), getOutputStream() already called
java.lang.IllegalStateException: UT010006: Cannot call getWriter(), getOutputStream() already called
at io.undertow.servlet.spec.HttpServletResponseImpl.getWriter(HttpServletResponseImpl.java:355)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:152)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:152)
Environment
- Liferay DXP
Resolution
-
This error may occurs as the reason may be anything like below example scenario:
- when you call the getOutputStream() on the response or the other ways like calling include() or forward() method after committing the response
- May be with your code logic where the output stream of the response might have been already opened by another piece of code. Like, when a servlet calls the getOutputStream() method on the response object for writing something after calling the include() method, Since JSP has already written the response on it hence again opening OutputStream on the response object is illegal, you might get the java.lang.IllegalStateException: getWriter() exception.
- For further assistance on resolving it, developer team or our Liferay Global Service team would be helping you on this implementation specific behaviour, as we, Liferay support assistance will be assisting you with our product specific things.
Additional Information
Please Note: Please choose to follow your appropriate discretion in the use of this information as these are not documented by Liferay.