Reputation: 413
When I send a large file using a post request the system shows an exception:
java.lang.IllegalStateException: Form too large1105723>200000
at org.mortbay.jetty.Request.extractParameters(Request.java:1404)
at org.mortbay.jetty.Request.getParameter(Request.java:749)......
When I search help for this in Google they give some help e.g.,
webappcontext.setMaxFormContentSize(5000000);
I am using this code but the problem is not solved
Also I am using the code
jettyServer.setAttribute("org.mortbay.jetty.Request.maxFormContentSize", 5000000);
But no result
Note:-I am using Jetty-6.1.0
Upvotes: 32
Views: 40767
Reputation: 21
set in jetty/webapps
-> configure .xml
(e.g jetty-web.xml
) file
"-1"
for unlimited content
<Set name="maxFormContentSize" type="int">600000</Set>
OR
<Set name="maxFormContentSize" type="int">-1</Set>
Upvotes: 1
Reputation: 2015
The problem here is with Jetty, on which ActiveMQ is based. You can find more details here, documentation
Solution is in apache-activemq-5.9.0/bin/win64/wrapper.conf
file, add the following line a after b (refer below).
wrapper.java.additional.16=-Dorg.eclipse.jetty.server.Request.maxFormContentSize=1000000
wrapper.java.additional.15=-Djava.security.auth.login.config=%ACTIVEMQ_CONF%/login.config
If you are running on a 32 bit computer, then please add the same line in apache-activemq-5.9.0/bin/win32/wrapper.conf
.
Happy Coding..
Upvotes: 0
Reputation: 21
I use Spring boot and set server.jetty.max-http-post-size: maxSize
in application.properties to fix it.
server.jetty.max-http-post-size: 500000
Upvotes: 1
Reputation: 838
If you use jetty in embedded mode,try this.
ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletHandler.setMaxFormContentSize(1024*1024*1024);//size you want to allow.
Upvotes: 1
Reputation: 11
Start jenkins by adding command line argument
-Dorg.eclipse.jetty.server.Request.maxFormContentSize=500000
i.e java -Dorg.eclipse.jetty.server.Request.maxFormContentSize=500000 -jar jenkins.war
Upvotes: 0
Reputation: 21
I use jetty 9.2.3.v20140905, and i fixed the problem use the follow:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.3.v20140905</version>
<configuration>
<jettyXml>
src/main/resources/jetty/jetty.xml
</jettyXml>
</configuration>
</plugin>
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg>
<Arg>-1</Arg>
</Call>
</Configure>
Upvotes: 2
Reputation: 25
I ran into a similar issue on ActiveMQ so i had to edit the jetty.xml and add
<property name="maxFormContentSize" value="-1" />
to the handler property.
from:-
<property name="handler">
<bean id="sec" class="org.eclipse.jetty.server.handler.HandlerCollection">
<property name="handlers">
<list>
<bean class="org.eclipse.jetty.webapp.WebAppContext">
<property name="contextPath" value="/admin" />
<property name="resourceBase" value="${activemq.home}/webapps/admin" />
<property name="logUrlOnStart" value="true" />
</bean>
to
<property name="handler">
<bean id="sec" class="org.eclipse.jetty.server.handler.HandlerCollection">
<property name="handlers">
<list>
<bean class="org.eclipse.jetty.webapp.WebAppContext">
<property name="contextPath" value="/admin" />
<property name="resourceBase" value="${activemq.home}/webapps/admin" />
<property name="logUrlOnStart" value="true" />
<property name="maxFormContentSize" value="-1" />
</bean>
Upvotes: 1
Reputation: 167
If you're running from eclipse/spring add the below to vm arguments -Dorg.mortbay.jetty.Request.maxFormContentSize=-1
Upvotes: 0
Reputation: 181
Unfortunately, I'm not able to make any changes to jetty.xml, so instead I simply set some options to adjust the maxFormContentSize like so:
JVM_OPTS="$JVM_OPTS -Dorg.eclipse.jetty.server.Request.maxFormContentSize=5000000"
This exists in the shell script that we use to launch our instance of Solr.
Upvotes: 5
Reputation: 3814
None of the above Solution worked for me ,
So in order to make this work I set the system property before creating the server, rather then setting it as server attribute
System.setProperty("org.eclipse.jetty.server.Request.maxFormContentSize", "500000000");
Server server = ServerFactory.createServer(host, port, contextPath, war);
Upvotes: 1
Reputation: 1995
Possibly because of changes in Jetty since version 7, but I only had success like so:
in jetty-web.xml, add the below to the Server object (1000000 is an example size, obv)
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg>
<Arg>1000000</Arg>
</Call>
full file might look something like mine
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg>
<Arg>1000000</Arg>
</Call>
<Ref id="DeploymentManager">
<Call id="webappprovider" name="addAppProvider">
<Arg>
(...)
ref http://wiki.eclipse.org/Jetty/Howto/Configure_Form_Size
Upvotes: 0
Reputation: 4000
Depending on how old your Jetty Version is you are using (in my case jetty-5.1.14 embedded in Eclipse Equinox), it also could be that the property needs to be org.mortbay.http.HttpRequest.maxFormContentSize
From: org.mortbay.http.HttpRequest
/**
* Max size of the form content. Limits the size of the data a client can push at the server.
* Set via the org.mortbay.http.HttpRequest.maxContentSize system property.
*/
public static int __maxFormContentSize = Integer.getInteger(
"org.mortbay.http.HttpRequest.maxFormContentSize", 200000).intValue();
So you need to do something like this in your application on startup to set the value:
System.setProperty("org.mortbay.http.HttpRequest.maxFormContentSize", "10000000");
Upvotes: 1
Reputation: 559
<!-- Development Jetty -->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.8.v20121106</version>
<configuration>
<scanIntervalSeconds>1</scanIntervalSeconds>
<webApp>
<contextPath>/${project.build.finalName}</contextPath>
</webApp>
<systemProperties>
<systemProperty>
<name>org.eclipse.jetty.server.Request.maxFormContentSize</name>
<value>10485760</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
Work for jetty 8 in maven plugin
Upvotes: 3
Reputation: 111
import org.mortbay.jetty.Server;
//... other code here...//
int port = 8080;
Server server = new Server(port);
server.setAttribute("org.mortbay.jetty.Request.maxFormContentSize", -1);
This code works on jetty 6.0.2 which I'm using.
The size of "-1" means the form has no limit I tryed to post a form large 20,000,000 bytes and I had no problem.
For eclipse releases of Jetty(jetty 7) you have to use the following code:
import org.eclipse.jetty.server.Server;
//... other code here...//
int port = 8080;
Server server = new Server(port);
server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", -1);
Upvotes: 11
Reputation: 5366
More documentation on form size: http://wiki.eclipse.org/Jetty/Howto/Configure_Form_Size
Upvotes: 4
Reputation: 240928
Try setting System properties via jetty.xml
<Call class="java.lang.System" name="setProperty">
<Arg>org.mortbay.jetty.Request.maxFormContentSize</Arg>
<Arg>500000</Arg>
</Call>
ok you can configure it from your web app
Add WEB-INF/jetty-web.xml file in your web application and configure the parameter in that file:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
"http://jetty.mortbay.org/configure.dtd">
<Configure id="WebAppContext" class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="maxFormContentSize" type="int">600000</Set>
</Configure>
Since version 7, Jetty's classes have moved to a different package. You must replace org.mortbay...
with org.eclipse...
(Thanks to David for his comment).
Upvotes: 34
Reputation: 413
webappcontext.getServletContext().getContextHandler() .setMaxFormContentSize(10000000);
Upvotes: 2
Reputation: 9436
I came across this problem too (running Jetty embedded in another application, so I'm not using jetty.xml).
I used the setMaxFormContentSize
method on the ContextHandler
class, which fixed the "form too large" exception. (See http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty#Setting_a_ServletContext for an example of creating/using a context handler).
Upvotes: 3