0

Returning to jetty-maven-plugin I've trouble to set buffers size.

My use-case imply file upload (usual size is ~700Ko). Because the upload is too big for jetty-maven-plugin default configuration I get Http response with error status code 413 (request too large)

I tryied using plugin configuration :

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>${jetty-maven.version}</version>
    <configuration>
        <scanIntervalSeconds>3</scanIntervalSeconds>

        <connectors>
            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                <port>8080</port>
                <maxIdleTime>60000</maxIdleTime>
                <requestHeaderSize>8192</requestHeaderSize>
                <requestBufferSize>2097152</requestBufferSize>
            </connector>
        </connectors>
    </configuration>
</plugin>

Then I tried to use jetty-maven-plugin with a jetty.xml file

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>${jetty-maven.version}</version>
    <configuration>
        <scanIntervalSeconds>3</scanIntervalSeconds>
        <jettyConfig>${basedir}/src/main/config/jetty/jetty.xml</jettyConfig>
    </configuration>
</plugin>

The jetty.xml is below:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"     "http://jetty.mortbay.org/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
 <Call name="addConnector">
  <Arg>
   <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
    <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
    <Set name="requestHeaderSize">8192</Set>
    <Set name="requestBufferSize">2097152</Set>
   </New>
  </Arg>
 </Call>
</Configure>

Nothing works. Could someone hand me the correct configuration please?

Sylvain
  • 731
  • 7
  • 9

3 Answers3

1

I'm not sure whether this fixes the problem in your use case, but you could try adding the following to your <configuration> section of the maven-jetty-plugin:

<systemProperties>
    <systemProperty>
        <name>org.eclipse.jetty.server.Request.maxFormContentSize</name>
        <value>-1</value> <!-- or any other value -1 is for max -->
     </systemProperty>
<systemProperties>

as mentioned by jesse mcconnell the property was renamed in jetty 7/8 to org.eclipse.jetty.server.Request.maxFormContentSize.

For jetty 6 for me org.mortbay.jetty.Request.maxFormContentSize is working.

Community
  • 1
  • 1
markus
  • 602
  • 4
  • 13
1

change your pom as per this and add this two xml file into your project. I hope, it will work for you.

        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.2.11.v20150529</version>
            <configuration>
                <contextPath>/random-api</contextPath>
                <scanIntervalSeconds>5</scanIntervalSeconds>
                <jettyXml>jetty.xml,jetty-http.xml</jettyXml>
            </configuration>
        </plugin>

===============jetty.xml and jetty-http.xml================= https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty.xml

https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-http.xml

redblood
  • 512
  • 1
  • 4
  • 17
0

After a pause (lunch) I grabed the code of the web-app I was supposed to test. There was a redundant limitation into its "internal" configuration (use an upload agent with it's own size limit).

In fact the two configuration proposed for jetty are working (now that web-app doesn't have any redundant limitation)

Sylvain
  • 731
  • 7
  • 9
  • Thanks for the help. As mentionned, the app-server setup was biased by what the app setup as restriction. In other words it was the app that refused large uploads and not the server. – Sylvain Sep 17 '12 at 13:01