13

I am getting the following error in my server log,

08-May-2018 12:00:07.460 SEVERE [https-jsse-nio-8443-exec-1] org.apache.catalina.core.ApplicationDispatcher.invoke Servlet.service() for servlet [jsp] threw exception java.lang.IllegalStateException: getOutputStream() has already been called for this response
    at org.apache.catalina.connector.Response.getWriter(Response.java:624)
    at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:211)
    at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:109)
    at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:109)
    at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:109)
    at org.springframework.security.web.util.OnCommittedResponseWrapper.getWriter(OnCommittedResponseWrapper.java:149)
    at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:118)
    at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:111)
    at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:176)
    at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:120)
    at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:75)
    at org.apache.jsp.WEB_002dINF.views.uncaughtException_html._jspService(uncaughtException_html.java:209)


    08-May-2018 12:00:07.468 SEVERE [https-jsse-nio-8443-exec-1] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [xyz] in context with path [] threw exception java.lang.IllegalStateException: getOutputStream() has already been called for this response] with root cause java.lang.IllegalStateException: getOutputStream() has already been called for this response     
    at org.apache.catalina.connector.Response.getWriter(Response.java:624)
    at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:211)
    at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:109)
    at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:109)
    at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:109)
    at org.springframework.security.web.util.OnCommittedResponseWrapper.getWriter(OnCommittedResponseWrapper.java:149)
    at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:118)
    at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:111)
    at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:176)
    at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:120)
    at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:75)
    at org.apache.jsp.WEB_002dINF.views.uncaughtException_html._jspService(uncaughtException_html.java:209)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

I do not know which method is throwing this error and what is the cause of this error. Actually this exception occured at the time when I deployed my application in tomcat and trying to get index page(Sometime first time, sometime second, sometime third the point is it comes no matter when it comes.), actually according to my configuration when ssl is enabled and when I deploy my application and trying to get welcome page session expired page is called and from now once I tried to get some other pages it throws the above exception. I am using spring 4 ,spring security, maven, hibernate 4. Can any one help me? Any Help will be appriciated.

web.xml

<web-app>
    <display-name>Smart app Application</display-name>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-security.xml, /WEB-INF/app-servlet.xml
        </param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <listener>
        <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
    </listener>

    <servlet>
        <servlet-name>app</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>app</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>jsp</servlet-name>
        <url-pattern>/WEB-INF/views/*</url-pattern>
    </servlet-mapping>

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>application</web-resource-name>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>

    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <welcome-file-list>
        <welcome-file>index</welcome-file>
    </welcome-file-list>

    <session-config>
        <session-timeout>50</session-timeout>
    </session-config>
</web-app>
Created Bylucky
  • 255
  • 4
  • 15

1 Answers1

0

If you have a SimpleMappingExceptionResolver try to check if you have conflicts with your ControllerAdvice annotated class. Exceptions have to be handled only in one place.

As I said, it could be generated by a cyclical in relationship and Jackason as serializer too. In this you have some options like use a DTO that simplifies the answer or user @JsonIgnore.