2 Replies Latest reply: May 3, 2013 9:52 AM by 996933 RSS

    java.lang.IllegalStateException

    996933
      Hey I am getting the below exception when running my huge application :

      java.lang.IllegalStateException: Cannot resize buffer - 319 bytes have already been written (Servlet 2.3, sec. 5.1)
      at weblogic.servlet.internal.ServletResponseImpl.setBufferSize(ServletResponseImpl.java:357)
      at weblogic.servlet.jsp.PageContextImpl.initialize(PageContextImpl.java:74)
      at weblogic.servlet.jsp.PageContextImpl.<init>(PageContextImpl.java:110)
      at weblogic.servlet.jsp.JspFactoryImpl.getPageContext(JspFactoryImpl.java:40)
      at jsp_servlet.__index._jspService(__index.java:62)
      at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
      at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
      at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
      at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:416)
      at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:327)
      at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:428)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at gov.hud.tool.web.controller.ServletFilter.doFilter(ServletFilter.java:108)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at gov.hud.tool.web.controller.LoginFilter.doFilter(LoginFilter.java:109)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
      at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
      at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
      at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
      at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
      >

      All I can figure out from this exception is, the error is caused from index.jsp.

      But my code works this way :

      web.xml -> index.jsp [ <META HTTP-EQUIV="Refresh" CONTENT="0;URL=index.action">] -> calls index.action mapping from ind-serv.xml (which is included in struts.xml) -> Action mapping calls another class, and passes arguments to this class, using <param> in action mapping.

      So it is kinda hard to debug, since all classes are interrelated.

      Any idea guys, why this error is occuring?
        • 1. Re: java.lang.IllegalStateException
          gimbal2
          I can't give you an answer directly but I can provide some hints about researching this stuff. It always starts with posting the error into google. However, you need to take out parts that are specific to you. So in this case I googled "java.lang.IllegalStateException: Cannot resize buffer bytes have already been written". This returns plenty of results without any clear answers in them, but there is one thing that I gather from them - it only happens on weblogic, I don't see the same error being reported in relation to Tomcat, Glassfish, JBoss, etc. etc. So you might want to try asking around in the Weblogic forums where there are likely people who have run into this before.

          https://forums.oracle.com/forums/category.jspa?categoryID=193
          • 2. Re: java.lang.IllegalStateException
            996933
            Thanks for letting me know that happens with weblogic.

            Just incase you/people who face similar error may be interested :
            From Servlet 2.3, sec 5.1 I came to know that,
            Servlets can do buffering to the clients for efficiency purpose, for which servlet request the size for buffering by using setBufferSize(). But this must happen before any content is written using Writer or ServletOutputStream or it results in IllegalStateException.