How to set the max size of upload file

Also in Spring boot 1.4, you can add following lines to your application.properties to set the file size limit: spring.http.multipart.max-file-size=128KB spring.http.multipart.max-request-size=128KB for spring boot 2.x and above its spring.servlet.multipart.max-file-size=10MB spring.servlet.multipart.max-request-size=10MB Worked for me. Source: https://spring.io/guides/gs/uploading-files/ UPDATE: Somebody asked the differences between the two properties. Below are the formal definitions: MaxFileSize: The maximum size allowed for … Read more

Tomcat logging confusion

If I’m understanding correctly you end up with a logging properties that looks like: java.util.logging.ConsoleHandler.level = FINER org.apache.catalina.realm.level = FINER The Java Logging Overview section 1.1 states: Applications make logging calls on Logger objects. Loggers are organized in a hierarchical namespace and child Loggers may inherit some logging properties from their parents in the namespace. … Read more

How do I load a java class (not a servlet) when the tomcat server starts [duplicate]

Let that class implement ServletContextListener. Then you can do your thing in contextInitialized() method. public class Config implements ServletContextListener { public void contextInitialized(ServletContextEvent event) { // Webapp startup. } public void contextDestroyed(ServletContextEvent event) { // Webapp shutdown. } } Register it in web.xml as follows to get it to run: <listener> <listener-class>com.example.Config</listener-class> </listener> Or if … Read more

Environment/system variables in server.xml

How it’s realized in my box. Bash-script for startup: #!/bin/sh SMEMORY=1G XMEMORY=1G if [ $ENV == DEV ]; then port_shutdown=”8005″ port_http=”8080″ port_https=”8443″ elif [ $ENV == SIT ]; then port_shutdown=”8006″ port_http=”8081″ port_https=”8444″ elif [ $ENV == UAT ]; then port_shutdown=”8007″ port_http=”8082″ port_https=”8445″ else echo “Unknown ENV” exit 1 fi export CATALINA_OPTS=” ${SYSTEM_PROPS} -d64 -server -Xms$SMEMORY … Read more

CORS – Tomcat – Geoserver

I need to do the same to avoid the usage of a proxy in OpenLayers. Since I’m running Ubuntu 12.04, I’ve installed Tomcat 7.0.55, instead of the default 7.0.26 (installed from packages). To add CORS headers, I simply added to $CATALINA_HOME/conf/web.xml the following lines: <filter> <filter-name>CorsFilter</filter-name> <filter-class>org.apache.catalina.filters.CorsFilter</filter-class> <init-param> <param-name>cors.allowed.origins</param-name> <param-value>*</param-value> </init-param> </filter> <filter-mapping> <filter-name>CorsFilter</filter-name> <url-pattern>/*</url-pattern> … Read more

Access Tomcat Manager App from different host

For Tomcat v8.5.4 and above, the file <tomcat>/webapps/manager/META-INF/context.xml has been adjusted: <Context antiResourceLocking=”false” privileged=”true” > <Valve className=”org.apache.catalina.valves.RemoteAddrValve” allow=”127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1″ /> </Context> Change this file to comment the Valve: <Context antiResourceLocking=”false” privileged=”true” > <!– <Valve className=”org.apache.catalina.valves.RemoteAddrValve” allow=”127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1″ /> –> </Context> After that, refresh your browser (not need to restart Tomcat), you can see the manager page.

Error starting Tomcat from NetBeans – ‘127.0.0.1*’ is not recognized as an internal or external command

Assuming you are on Windows (this bug is caused by the crappy bat files escaping), It is a bug introduced in the latest versions (7.0.56 and 8.0.14) to workaround another bug. Try to remove the ” around the JAVA_OPTS declaration in catalina.bat. It fixed it for me with Tomcat 7.0.56 yesterday. In 7.0.56 in bin/catalina.bat:179 … Read more