Arquivo da tag: Tomcat

Tomcat – java.lang.OutOfMemoryError: PermGen space

Apache Tomcat is widely used Web Container in the world. Very big companies run on Apache Tomcat now a days. There are quite a few other alternatives like IBM WebSphere, Geronimo, IIS, etc. but Tomcat is my favorite one too.

It’s very critical for us to configure all correct parameters while running your application in Production environment or even in development env.

In this tutorial we will go over steps on how to configure -Xms, -Xmx and -XX:PermSize value for Tomcat server. Let’s first understand few terms.


Specifies the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or Kto indicate kilobytes, or m or M to indicate megabytes. The default value is 64MB. The upper limit for this value will be approximately 4000m on Solaris 7 and Solaris 8 SPARC platforms and 2000m on Solaris 2.6 and x86 platforms, minus overhead amounts. So, in simple words, you are saying Java to use Maximum of 1024 MB from available memory.

NOTE: there is NO SPACE between -Xmx and 1024m


It’s a size of the heap for the young generation.


It’s used to set size for Permanent Generation. It is where class files are kept.

Another must readChange -Xmx value of Tomcat in Eclipse IDE

Let’s get started:

Below are the simple steps to change -Xmx / -Xms values or other JVM parameters if you are running Tomcat from command prompt.


Download Apache Tomcat.


Go to Apache Tomcat /bin directory.

Create file for Tomcat Xmx and Xmn value - Crunchify Tips


By default you wont see (for Linux/Mac) or setenv.bat (for windows) file under /bin directory. You have to create one with below parameters.


  1. Go to command prompt.
  2. Go to <Tomcat Directory>/bin directory
  3. Execute command: ./ run

Run Apache Tomcat using run command - Crunchify


Monitor logfile and you should see your Tomcat started with all your specified parameters in file.

Apache Tomcat Log with Xmx and Xmn value - Crunchify Tips

PS: For Windows environment you need to create setenv.bat file and run Tomcat with catalina.bat

Join the Discussion

Share & leave us some comments on what you think about this topic or if you like to add something.


Editar vim e adicionar a linha:

export JAVA_OPTS="-Dfile.encoding=UTF-8 -Xms1024m -Xmx6024m -XX:PermSize=256m -XX:MaxPermSize=1024m"

Share and Enjoy !

0 0

How to stop Logging on Apache Tomcat6 or Tomcat7 solr server to catalina out

So, according to documentation all logging functionality can be manipulated in file which is usually located under apache tomcat root installation folder, which in ubuntu case is under /etc/tomcat6/…

Opening a file you’d probably spot logging level settings (set to FINE as default), well We want to get rid of logging at all, so, according to this helping post I needed to change ConsoleHandler level to OFF.

I changed;

java.util.logging.ConsoleHandler.level = FINE


java.util.logging.ConsoleHandler.level = OFF

And happily I got the result Apache Tomcat6 solr server stopped logging to catalina.out

Share and Enjoy !



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”);

Share and Enjoy !



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


Share and Enjoy !



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"/>

Share and Enjoy !



Gradle plugin supporting deployment of your web application to an embedded Tomcat web container

Share and Enjoy !

0 0