How to solve the "Form too large" error in Jetty?

Last modified by Sebastian Klipper on 2024/12/27

This happens because Jetty has a default size for accepting POST data, which can be customized.

If you're using the XWiki Zip distribution, you can edit XWIKI_INSTALL_DIR/jetty/etc/jetty.xml and/or XWIKI_INSTALL_DIR/jetty/etc/jetty-ee8-web.xml and locate the following configuration:

<Configure class="org.eclipse.jetty.ee8.webapp.WebAppContext">
 <!-- In order to avoid getting a "java.lang.IllegalStateException: Form too large" error when editing large page in
       XWiki we need to tell Jetty to allow for large content since by default it only allows for 20K. We do this by
       passing the "org.eclipse.jetty.server.Request.maxFormContentSize" attribute.
       Note 1: Setting this value too high can leave your server vulnerable to denial of service attacks.
       Note 2: We're setting it here instead of in Jetty's XML configuration files so that the XWiki WAR can be used
       in any Jetty config and work out of the box.
  -->

 <Set name="maxFormContentSize">1000000</Set>
 <!-- Increasing the maxFormKeys in order to be able to import correctly a full wiki (more than 1000 pages in 11.10).
       The import should be fixed at a point to allow importing everything without creating a form with a field by
       page. Once done this configuration can be removed. See https://jira.xwiki.org/browse/XWIKI-11597 for a follow
       up.
  -->

 <Set name="maxFormKeys">2000</Set>
</Configure>

If you're using a different distribution you can simply set the JVM System Property org.eclipse.jetty.server.Request.maxFormContentSize to the value you wish (e.g. -Dorg.eclipse.jetty.server.Request.maxFormContentSize=1000000). You should set this in the JVM options you use when starting the Servlet Container in which XWiki is deployed.

Get Connected