Legacy Knowledge Base
Published Sep. 10, 2025

java.lang.IllegalStateException: UT010006: Cannot call getWriter(), getOutputStream() already called

Written By

Thanga Meena

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

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

Did this article resolve your issue ?

Legacy Knowledge Base