Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem with Jetty: java.lang.IllegalStateException: Commited and java.lang.IllegalStateException: Not EDITABLE exceptions under load

Posted on 2004-10-31
10
Medium Priority
?
746 Views
Last Modified: 2010-08-05
I have the following JSP code:
<%@ page buffer="128kb" errorPage="/jsp/Error.jsp" isThreadSafe="true"%>
...
<%
    response.setContentType("text/html; charset="+Config.getInstance().getEncoding());
    response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
    response.setHeader("Pragma","no-cache"); //HTTP 1.0
    response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
...
    String lastPath = request.getParameter("last_path");
    if (lastPath != null) {
        if(URLDecoder.decode(lastPath, "UTF-8").indexOf("TSFrame.jsp?ID=") != -1) {
            redirect(lastPath);
            return;
        } else if(URLDecoder.decode(lastPath, "UTF-8").indexOf("TSFrame.jsp") == -1){
            session.setAttribute("MAIN_FRAME_GO_TO", lastPath);
            redirect(request.getContextPath() + "/jsp/TSFrame.jsp");
            return;
        }        
    }
    redirect(request.getContextPath() + "/jsp/SwitchAction.jsp");

%>

Under low load all works fine, but under high load I got following exception:
java.lang.IllegalStateException: Commited
      at org.mortbay.http.HttpResponse.sendRedirect(HttpResponse.java:448)
      at
org.mortbay.jetty.servlet.ServletHttpResponse.sendRedirect(ServletHttp
Response.java:432)
      at jsp.login.LoginAction_jsp.redirect(LoginAction_jsp.java:43)
      at jsp.login.LoginAction_jsp._jspService(LoginAction_jsp.java:173)
      at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

Also I got the following under load:
16:49:26.234 WARN!! GET
/TrackStudio/jsp/task/subtasks/Subtasks.jsp?ID=651 HTTP/1.1
java.lang.IllegalStateException: Not EDITABLE
      at org.mortbay.http.HttpMessage.setVersion(HttpMessage.java:542)
      at
org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:913)
      at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
      at
org.mortbay.http.SocketListener.handleConnection(SocketListener.java:2
18)

How this can happend ? Seems like we don't send any content before redirect and have enough buffer.

0
Comment
Question by:maximkr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 13

Expert Comment

by:petmagdy
ID: 12458324
please try to increase the jetty Java memory process like this:

java -Xms256m -Xmx512m
0
 

Author Comment

by:maximkr
ID: 12458731
Don't help. I don't think that problem is the load itself, the bug occurs only on this page when several users login the same time. Just test it: 5 users login the same time and  4 of them got this exception. It have no chance to eat all memory/threads/etc

The second (Not EDITABLE) exception also occurs only on the specific page.
0
 

Author Comment

by:maximkr
ID: 12458738
Another strange exception under load:

java.lang.IllegalStateException: BAD is not EDITABLE
      at org.mortbay.http.HttpResponse.writeHeader(HttpResponse.java:248)
      at org.mortbay.http.BufferedOutputStream.writeHeader(BufferedOutputStream.java:105)
      at org.mortbay.http.HttpOutputStream.writeHeader(HttpOutputStream.java:420)
      at org.mortbay.http.HttpConnection.commit(HttpConnection.java:717)
      at org.mortbay.http.HttpConnection.outputNotify(HttpConnection.java:530)
      at org.mortbay.http.HttpOutputStream.notify(HttpOutputStream.java:556)
      at org.mortbay.http.HttpOutputStream.outputNotify(HttpOutputStream.java:541)
      at org.mortbay.http.BufferedOutputStream.flush(BufferedOutputStream.java:178)
      at org.mortbay.http.ChunkingOutputStream.flush(ChunkingOutputStream.java:67)
      at org.mortbay.http.HttpOutputStream.flush(HttpOutputStream.java:486)
      at org.mortbay.http.HttpResponse.commit(HttpResponse.java:489)
      at org.mortbay.http.HttpResponse.sendRedirect(HttpResponse.java:451)
      at org.mortbay.jetty.servlet.ServletHttpResponse.sendRedirect(ServletHttpResponse.java:432)
      at jsp.SwitchAction_jsp.redirect(SwitchAction_jsp.java:69)
      at jsp.SwitchAction_jsp._jspService(SwitchAction_jsp.java:213)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:maximkr
ID: 12458904
Just tried with Tomcat 4 - the same problems:

java.lang.IllegalStateException
        at org.apache.catalina.connector.HttpResponseFacade.sendRedirect(HttpResponseFacade.java:173)
        at org.apache.jsp.LoginAction$jsp.redirect(LoginAction$jsp.java:56)
        at org.apache.jsp.LoginAction$jsp._jspService(LoginAction$jsp.java:216)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
0
 
LVL 13

Expert Comment

by:petmagdy
ID: 12458924
why r u using redirect, r u redirecting to a Web component outside ur Tomcat or jetty?

please explain what do loginaction do
0
 

Author Comment

by:maximkr
ID: 12458974
No, LoginAction just check that username/password is correct, update cookies (set new password to cookies) and redirect to page that actually show data. I found the following topic:
http://www.jguru.com/faq/view.jsp?EID=501393

It seems that we got this problem because we can't set cookie and redirect in the same servlet. But I don't understand how to handle this correctly - where we should set up cookies ?
0
 
LVL 13

Expert Comment

by:petmagdy
ID: 12458987
is this struts action, or normal servlet?
0
 

Author Comment

by:maximkr
ID: 12459000
Its JSP with
<%
at the begin and
%>
at the end.

Please see code sample in the very first message
0
 
LVL 13

Accepted Solution

by:
petmagdy earned 1500 total points
ID: 12459050
sorry i missed to look at the begining of the thread

first move the first 4 lines of:

   response.setContentType("text/html; charset="+Config.getInstance().getEncoding());
    response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
    response.setHeader("Pragma","no-cache"); //HTTP 1.0
    response.setDateHeader ("Expires", 0); //prevents caching at the proxy server

to the redirected jsps

second instead of sendRedirect use forward like this:

    getServletConfig().getServletContext().getRequestDispatcher("SwitchAction.jsp").forward(request,response);

the jsp provided is relative path, assuming that all ur jsp r in the same directory, please try this and tell me the result




0
 

Author Comment

by:maximkr
ID: 12459183
Got some problems with paths (it can't find SwitchAction.jsp, will investigate tomorrow) and the following warning:

Invalid length: Content-Length=1304 written=1410 for http://localhost:8888/TrackStudio/jsp/login/LoginAction.jsp

Seems like some headers was sent before.

But I still have 2 major questions:
1) Why buffers don't work ? I expect that 128 k should be enough to store all headers before we finish page generation.
2) In LoginAction.jsp we also setup cookies. As I understand, I can't setup cookies in servlet that forward or redirect control. How we should to setup it ?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With the evolution of technology, we have finally reached a point where it is possible to have home automation features like having your thermostat turn up and door lock itself when you leave, as well as a complete home security system. This is a st…
WooCommerce is becoming the most powerful e-commerce plugin for Wordpress. And why not. The platform comprises of numerous core plugins that may come in handy, powerful options to make your website development task much easier.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question