Arquivo da categoria: Tomcat

Spring Boot Tomcat Configuration, migration from container to embedded

I’m migrating a Spring boot application that used to run in the Tomcat container to a Spring Boot application that runs an embedded Tomcat. My old Tomcat configuration has these configurations in the server.xml:
[code type=xml]

I was able to set up most of the properties using a bean
[code type=java]
public EmbeddedServletContainerFactory embeddedServletContainerFactory() {
TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory = new TomcatEmbeddedServletContainerFactory();
tomcatEmbeddedServletContainerFactory.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> {
AbstractHttp11JsseProtocol handler = (AbstractHttp11JsseProtocol)connector.getProtocolHandler();

return tomcatEmbeddedServletContainerFactory;

[code type=properties]
server.tomcat.accept-count = 500
server.tomcat.max-threads = 600
server.port = 8080
server.max-http-header-size = 32768
server.connection-timeout = 20000

However I cannot figure out how to set this part
[code type=properties]
server=”My server”

Can anyone help me please? Thank you

Try this:
[code type=java]
connector.setProperty(“useComet”, Boolean.toString(false));
connector.setProperty(“socket.appReadBufSize”, “87380”);
connector.setProperty(“socket.rxBufSize”, “87380”);
connector.setProperty(“socket.performanceConnectionTime”, “2”);
connector.setProperty(“socket.performanceLatency”, “0”);
connector.setProperty(“socket.performanceBandwidth”, “1”);
connector.setProperty(“server”, “My server”);

How to change Tomcat to use JDK 7

The current environment is using Tomcat 7 + JDK 6. How to configure Tomcat to use JDK 7?


  1. Tomcat 7 (apt-get install)
  2. Debian 7.5
  3. JDK 6 and JDK 7

P.S Tomcat 7 is installed via apt-get

You may interest at this tutorial – Apache Tomcat 8 + JDK 8 on Debian

1. Solution

Update the JAVA_HOME in this file /etc/default/tomcat7

1.1 Edit /etc/default/tomcat7, update JAVA_HOME

$ sudo vim /etc/default/tomcat7

# The home directory of the Java development kit (JDK). You need at least
# JDK version 1.5. If JAVA_HOME is not set, some common directories for
# OpenJDK, the Sun JDK, and various J2SE 1.5 versions are tried.


1.2 Restart Tomcat, done.

$ sudo service tomcat7 restart

1.3 Check this article to find out which JDK is used by Tomcat.

No SPACE, What the F!
Make sure there is no extra space between the equal symbol “=”, it will cause “JAVA_HOME no found”, I spent hours fixing this bug!For example

#...Wrong, SPACE
JAVA_HOME = /usr/lib/jvm/java-7-openjdk-amd64


How to change Tomcat to use JDK 7

How to fix Tomcat WARNING: An attempt was made to authenticate the locked user?

The warning above means that you fail to authenticate the user tomcat more than once. Tomcat suspects that it is brute force attack on the user tomcat.

What authentication you use in your application? What login-config you use in web.xml of the application?

The default configuration of resourceName “UserDatabase” is the file conf/tomcat-users.xml. Did you change the configuration of resourceName “UserDatabase”?

You can find the configuration of the resource UserDatabase in the file server.xml:

<Resource name="UserDatabase" auth="Container"
              description="User database that can be updated and saved"
              pathname="conf/tomcat-users.xml" />

By default all users are commented. To be able to work with users from the XML file you should uncomment. Then, you will be able to login with user tomcat:

  <role rolename="tomcat"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>

Trocando porta do Tomcat da 8080 para 80 no Linux

1) Vá na pasta “conf” no diretório de instalação do tomcat.
Exemplo de caminho:


2) Abra o arquvivo “server.xml”.

3) Troque a port=8080 para port=80.

4) Salve o arquivo.

5) Edite as configurações do Tomcat.
Exemplo de caminho:

sudo vi /etc/default/tomcat7

6) Remova o # que simboliza um comentário e troque o NO por YES.


7) Instale o Authbind.

sudo apt-get install authbind

8) Execute esses comandos para fazer o Tomcat executar na porta 80:

sudo touch /etc/authbind/byport/80
sudo chmod 500 /etc/authbind/byport/80
sudo chown tomcat7 /etc/authbind/byport/80

9) Restart o Tomcat.

sudo service tomcat7 restart