3

I'm working on a Wildfly Swarm project (using Wildfly Swarm version 2017.8.1, Maven 3.5.0, OpenJDK 1.8.0_141) where users will often upload files WAY bigger than Undertow's default 10485760 bytes (10MB) max-post-size setting.

I see from other questions that what I need to change is the key swarm.undertow.servers.default-server.http-listeners.default.max-post-size.

To try this setting out, I put it on the command line when I start the jar:

java -jar project-swarm.jar -Dswarm.undertow.servers.default-server.http-listeners.default.max-post-size=4000000000

This worked. The following also works if I want to run it using the Wildfly Swarm maven plugin:

mvn wildfly-swarm:run -Dswarm.undertow.servers.default-server.http-listeners.default.max-post-size=4000000000

Using either of the above two commands I can upload files bigger than 10485760 bytes (10MB). The next step is to make this the default so that I don't have to pass it in via command line each time. The official Wildfly Swarm configuration documentation said that I should put the undertow setting in a project-defaults.yml file. This is what that looks like for me:

swarm:
  undertow:
    servers:
      default-server:
        http-listeners:
          default:
            max-post-size: 4000000000

The thing is, none of that documentation says WHERE the file should ultimately end up. Should it end up as part of the war, under WEB-INF/classes, or the root of the war, or somewhere else? From the wildfly-swarm examples repo on github, usually the project-defaults.yml file is insrc/main/resources`, which is where I had it originally. However, it didn't work for me. Any attempts to upload a file bigger than 10485760 bytes (10MB) fail.

I found out that anything in a maven project that is put into src/main/resources gets put into the war file's /WEB-INF/classes (and the war file itself is wrapped by the swarm jar). So, I updated my maven pom so that the project-defaults.yml would be stored in the base directory of the war file itself. This STILL didn't work.

Next, I tried putting project-defaults.yml in the swarm jar itself, rather than the enclosed war. Yet again, I could not break past the 10485760 bytes (10MB) max-post-size default.

Finally, I tried using the command line option to refer to an external yml file, like so:

java -jar project-swarm.jar -s../src/main/root-resources/project-defaults.yml

This loaded the file, but alas I was STILL STUCK at the default max-post-size of 10485760 bytes (10MB).

At this point, I'm stumped. My project-defaults.yml file might be wrong or I'm not putting it in the right location. How do I fix this so I can upload files bigger than 10485760 bytes (10MB) and specify it via the project-defaults.yml file?

Redsaz
  • 53
  • 1
  • 5
  • 1
    As you pointed out, our examples have it present within src/main/resources of a project. That location should work. You can add "-Dswarm.logging=DEBUG" to see if your setting is appearing in the list outputted on startup. Otherwise, raise an issue with a way to reproduce here: https://issues.jboss.org/browse/SWARM – Ken Aug 20 '17 at 20:24

1 Answers1

7

For those searching for an answer to this question, you have two alternatives for placing project-defaults.yml in your project.

Use Default Location

src/main/resources/project-defaults.yml

Use Maven Resource Declaration

Place the file somewhere else, for example: src/main/java/project-defaults.yml

Then, declare it as a resource using maven inside of the build section like so:

<build>
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>project-defaults.yml</include>
            </includes>
        </resource>
    </resources>
</build>
KG6ZVP
  • 3,610
  • 4
  • 26
  • 45