Jetty submit data times java.lang.IllegalStateException:Form too large270468>200000 problem resolution

Source: Internet
Author: User

Today, when using Eclipse's jetty plugin as a server to submit data in rich text editing, the following exception is reported:

Java.lang.IllegalStateException:Form too large270468>200000At org.mortbay.jetty.Request.extractParameters (Request.java:1561) at Org.mortbay.jetty.Request.getParameterMap (Request.java:870) at Org.apache.struts2.dispatcher.Dispatcher.createContextMap (Dispatcher.java:528) at Org.apache.struts2.dispatcher.ng.PrepareOperations.createActionContext (Prepareoperations.java:78) at Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter.doFilter (Strutspreparefilter.java:74) at Org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter (Servlethandler.java:1212) at Org.mortbay.jetty.servlet.ServletHandler.handle (Servlethandler.java:399) at Org.mortbay.jetty.security.SecurityHandler.handle (Securityhandler.java:216) at Org.mortbay.jetty.servlet.SessionHandler.handle (Sessionhandler.java:182) at Org.mortbay.jetty.handler.ContextHandler.handle (Contexthandler.java:766) at Org.mortbay.jetty.webapp.WebAppContext.handle (Webappcontext.java:450) at Org.mortbay.jetty.handler.HandlerWrapper.handle (Handlerwrapper.java:152) at Org.mortbay.jetty.Server.handle (Server.java:326) at Org.mortbay.jetty.HttpConnection.handleRequest (Httpconnection.java:542) at Org.mortbay.jetty.httpconnection$requesthandler.content (Httpconnection.java:945) at Org.mortbay.jetty.HttpParser.parseNext (Httpparser.java:756) at org.mortbay.jetty.HttpParser.parseAvailable (Httpparser.java:218) at Org.mortbay.jetty.HttpConnection.handle (Httpconnection.java:404) at Org.mortbay.io.nio.SelectChannelEndPoint.run (Selectchannelendpoint.java:410) at Org.mortbay.thread.queuedthreadpool$poolthread.run (Queuedthreadpool.java:582)

It is obvious that the single request data is too large, Form too large>200000 (200000 that is, 200000Byte about 2M), but where the exception is thrown out, after a study, found that the jetty plug-in reported the following:

Under the \eclipse\plugins directory, locate org.mortbay.jetty.server_6.1.23. V201012071420.jar bag, throw into the Jd-gui, according to the error message Information Org.morbay.jetty.Request.extractParameters () method to find the following information:

Notice that the arrows show that the exception should be thrown out here, but the maxformcontentsize value is from there, according to This._context.getcontexthandler (). Getmaxformcontentsize () This hint, find the Org.mortbay.jetty.handlerContextHandler.class class, the result found that the class has the following sentence, excited, the default value here.

So the default value is set, how to modify it, by looking at the This._context.getcontexthandler (). Getmaxformcontentsize () code in the request class, continue tracking, This value should be obtained from the Web portal, that is, XML, but how this value is passed in, after the online search and practice, you can create a new Jetty-web.xml file in the Web-inf directory, the following content, the Maxformcontentsize re-assigned to the value can be (Jetty6 Use):

<?XML version= "1.0"?><!DOCTYPE Configure Public "-//mort Bay consulting//dtd configure//en" "Http://jetty.mortbay.org/configure.dtd" >  <ConfigureID= "Webappcontext"class= "Org.mortbay.jetty.webapp.WebAppContext">       <Setname= "Maxformcontentsize"type= "int">6000000</Set>  </Configure>  

Restart the web app, submit the data again, find that it can be submitted properly, and the problem will be solved satisfactorily.

So other servers have a similar situation, the answer is of course yes, such as Tomcat, through the search found the following:

Q:in Tomcat, I got a "Post data too big" error.
A:apache Tomcat By default sets a limit on the maximum size of HTTP POST requests it accepts.
In Tomcat 5, the This limit was set to 2097152 (2 Mb). When you try to upload files or post forms that is
Larger than 2 MB, this error can occur.

The solution is to reconfigure Tomcat to accept larger POST requests, either by increasing
The limit, or by disabling it. This can is done by editing Tomcat ' s server.xml.
In the <Connector> element, add an attribute "Maxpostsize" and set a larger value (in bytes) to
Increase the limit. Setting it to 0 would disable the size check.

This means that the tomcat default setting can receive HTTP POST requests up to 2M in size, and if your post request passes more than 2M of data, this error will be reported. The workaround is to modify the TOMCAT configuration file $tomcat_home$/conf/ Server.xml, find the <Connector> tag inside, add the "Maxpostsize" attribute to the tag, set the value of the property to the maximum value you want, the unit is byte, if you set this value to 0 (maxpostsize= "0"), Tomcat will no longer check the size of the post.

I test the environment as follows:

Jetty version: Run Jetty run Feature1.2.2.1

Jetty the corresponding JAR package version: Org.mortbay.jetty.server_6.1.23.v201012071420.jar

For Jetty7 just change the path of the package, the complete configuration file is as follows:

<?XML version= "1.0"?><!DOCTYPE Configure Public "-//mort Bay consulting//dtd configure//en" "Http://jetty.mortbay.org/configure.dtd" >  <ConfigureID= "Webappcontext"class= "Org.mortbay.jetty.webapp.WebAppContext">       <Setname= "Maxformcontentsize"type= "int">6000000</Set>  </Configure>  

Oh, it's done!

This article is reproduced from http://blog.csdn.net/shixing_11/article/details/6996236#

Jetty submit data times java.lang.IllegalStateException:Form too large270468>200000 problem resolution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.