3

When running spring-boot with tomcat-embedded, how do I set/change these tomcat-config system-properties?

I tried just adding -D... on the commandline, but doesnt seem to work.

Rop
  • 3,359
  • 3
  • 38
  • 59
  • 1
    you may have a look at [common application properties](https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html) & [Embedded servlet containers](https://docs.spring.io/spring-boot/docs/current/reference/html/howto-embedded-servlet-containers.html) – Amit Phaltankar Jun 06 '17 at 00:30
  • your 1st links provides, I guess, spring-equivalents for a few of the tomcat system-properties above, but there are many more in the tomcat-doc... your 2nd link -- hard to digest I think.... there is no simple way to just set the tomcat-doc properties when running embedded? or an example/link how to use configurators, etc, if required to achieve it, would be helpful. – Rop Jun 06 '17 at 19:45
  • The second link leads to 404... – Matthias Lohr Jul 28 '18 at 14:35
  • 1
    The 2nd link should be: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-customizing-embedded-containers – Peter Wippermann Mar 23 '21 at 14:54

2 Answers2

1

I am currently defining one of the catalina.properties via command line when starting my spring-boot application.

The property we are adding is: tomcat.util.http.parser.HttpParser.requestTargetAllow

The complete command I use to run the application is:

mvn -Dtomcat.util.http.parser.HttpParser.requestTargetAllow={} spring-boot:run

You should be able to append more catalina properties as follows:

mvn -Dtomcat.util.buf.StringCache.byte.enabled=true -Dtomcat.util.http.parser.HttpParser.requestTargetAllow={} spring-boot:run

And you could add any of the properties you mentioned here: https://tomcat.apache.org/tomcat-8.5-doc/config/systemprops.html

I ended up with this solution with the help of following posts:

https://bz.apache.org/bugzilla/show_bug.cgi?id=60594

Invalid character found in the request target in spring boot

Let me know if it works for you.

0

I put the -D properties in the .conf like such:

JAVA_OPTS="$JAVA_OPTS -Dtomcat.util.http.parser.HttpParser.requestTargetAllow={}

That's the way you do it for deployments, the maven style by Alvaro Lazaro is more for development purposes.

Frischling
  • 2,100
  • 14
  • 34