title: How to change Jetty settings through SparkJava? / Form too Large Exception / org.eclipse.jetty.server.Request.maxFormContentSize
body: <p>I'm using SparkJava 2.2 which is using Jetty 9.0.2.</p>
  
  <p>I'm getting "Form too large" exception which is thrown by Jetty. I already know how to solve this problem if I was using Jetty directly:</p>
  
  <p><a href="https://stackoverflow.com/questions/3861455/form-too-large-exception">Form too Large Exception</a></p>
  
  <p><a href="http://www.eclipse.org/jetty/documentation/current/setting-form-size.html" rel="nofollow noreferrer">http://www.eclipse.org/jetty/documentation/current/setting-form-size.html</a></p>
  
  <p>PROBLEM :</p>
  
  <p>Now I need to find a way to change <code>org.eclipse.jetty.server.Request.maxFormContentSize</code> setting through SparkJava. Is there a way to do this? </p>
  
  <p>I must note that other methods (JVM_OPTS, System.setProperty) do not work for me for some reason. I'm still getting the same exception.</p>
  
  <p>Stacktrace:</p>
  
  <pre><code>[qtp1858644635-27] ERROR spark.webserver.MatcherFilter -
  java.lang.IllegalStateException: Form too large 308913&gt;200000
      at org.eclipse.jetty.server.Request.extractParameters(Request.java:334)
      at org.eclipse.jetty.server.Request.getParameterMap(Request.java:765)
      at javax.servlet.ServletRequestWrapper.getParameterMap(ServletRequestWrapper.java:193)
      at spark.QueryParamsMap.&lt;init&gt;(QueryParamsMap.java:59)
      at spark.Request.initQueryMap(Request.java:364)
      at spark.Request.queryMap(Request.java:349)
      at spark.webserver.RequestWrapper.queryMap(RequestWrapper.java:213)
      at com.xyz.analytics.webservice.RequestTools.getRequestQueryMap(RequestTools.java:27)
      at com.xyz.analytics.webservice.RequestTools.getMandrillQueryParams(RequestTools.java:22)
      at com.xyz.analytics.webservice.Endpoints.lambda$initiateEndpointsAndExceptionHandlers$2(Endpoints.java:61)
      at com.xyz.analytics.webservice.Endpoints$$Lambda$3/1485697819.handle(Unknown Source)
      at spark.SparkBase$1.handle(SparkBase.java:311)
      at spark.webserver.MatcherFilter.doFilter(MatcherFilter.java:159)
      at spark.webserver.JettyHandler.doHandle(JettyHandler.java:60)
      at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:179)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
      at org.eclipse.jetty.server.Server.handle(Server.java:451)
      at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:252)
      at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:266)
      at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:240)
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:596)
      at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:527)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <h1>Edit:</h1>
  
  <blockquote>
    <p>I must note that other methods (JVM_OPTS, System.setProperty) do not work for me. </p>
  </blockquote>
  
  <p>Well, debugger doesn't even stop at any breakpoint set within <code>org.eclipse.jetty.server.handlerContextHandler</code>... Plus when it stops at <code>org.eclipse.jetty.server.Request</code> breakpoints, _context property is null. Seems that SparkJava is handling it differently. Dead end.</p>
  
  <p>Request does one more thing before setting <code>maxFormContentSize = 200000;</code>. It checks _channel.getServer().getAttribute("org.eclipse.jetty.server.Request.maxFormContentSize"). 
  Except Server's attribute collection is empty... And I don't see any way to add any attribute. Jetty Server is created by SparkBase.init() which calls SparkServer.ignite(). 
  But it doesn't help us much. It's not easy to "break in" to make our own adjustments. It seems pretty hopeless.</p>