TomcatExpert

Ask the Experts

Send us your questions on how to improve, troubleshoot or manage your Apache Tomcat deployment. Our team of Apache Tomcat committers and community leaders will review all submitted questions, and post the most relevant questions along with an answer from a real Tomcat Expert. The questions and answers will be made public for the community to collectively learn from and discuss.

Questions submitted are not guaranteed to be posted. The selection process will favor  questions of the day that are the most interesting, timely, or relevant to our community.  Ensuring your questions is concise, well written, and without annoying broken links, bad grammar or spelling errors will help your question to be answered more readily by the  Community Moderators.

Ask the Experts : Out of Memory - Out of swap space

 

asked by sunilatte

question

This is a regular OutOfMemoryError in the Java Heap, you are receiving the error cause

  • You have set -Xmx too low or
  • You have a memory leak in your application

The reason the JVM crashes, is cause you are using a very old JVM, I suggest you

  1. Upgrade your JVM to the latest 1.6.0 release
  2. Use a 64 bit JVM
  3. Increase -Xmx

If you are still seeing an OutOfMemoryError after that, you probably have a memory leak. For that you can use a profile to analyze your memory usage. I prefer YourKit

answered by fhanik on August 30, 2012 04:10 PM

Read More

answer

26 comments   |  

5
Rating
  |  

| out of memory

Ask the Experts : Tomcat hangs on production and doesn’t respond to new http requests.

 

We are having issues with tomcat on production. Tomcat hangs on production and doesn’t respond to new http requests.

asked by gaurav

question

7.0.11 was a very early release and most likely you are running into a bug. I would upgrade to 7.0.27. Even in that release, there are reports of the system hanging -

https://issues.apache.org/bugzilla/show_bug.cgi?id=53173

The bug above shows how a newly introduced feature in Tomcat 7, has had an issue in all released versions.

There are a few work arounds

  1. Use Tomcat 6 - this release is unaffected by the bug above
  2. Wait for next release of Tomcat 7
  3. Increase maxConnections value to delay the symptom of this problem

 

answered by fhanik on June 4, 2012 03:59 AM

Read More

answer

313 comments   |  

0
Rating
  |  

Developers | hangs, TCP, Tomcat

Ask the Experts : Debugging JBoss

I have been running Tomcat 6.0.24 in a Netbeans development environment for months.  Yesterday, I started getting a "java.lang.NoClassDefFoundError: org/jboss/logging/Logger" message when I try to start Tomcat in Netbeans services.  I'm not running jboss, and to my knowledge, I haven't made any changes to my computer.  The server output is:

asked by rhurdle

question

Most likely you have a jboss jar somewhere in your system.

To troubleshoot this, I recommend enabling the -XX:+TraceClassLoading option, and then scan the output for what library it is trying to load your classes from.

answered by fhanik on June 12, 2012 08:04 AM

Read More

answer

40 comments   |  

0
Rating
  |  

Developers | netbeans, Tomcat 6.0, Tomcat Administration

Ask the Experts : Disable caching/force reloading of JNDI resources

The idea was to provide multiple web applications running inside a Tomcat instance with configuration properties from config files located outside the WAR file of the applications. I'm currently trying to provide these configuration properties with a global naming resource (defined inside the server.xml) which is consumed by the said applications to keep the configuration container independent and to avoid direct file access from a web application. So far almost everything already works perfectly! Except that Tomcat obviously caches resources which are looked up via JNDI.

asked by

question

There is sort of a way to get this happen. It is not a cache, instead it is singleton or non singleton.

Take the default example that ships with Tomcat

 

<Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
 
With this configuration, getObjectInstance will only be called once. However, there is an attribute that can be set that will make sure that getObjectInstance is called every time a Context.lookup happens, it is singleton="false" 
 
<Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml"
              singleton="false"/>

Then you are able to decide when getObjectInstance returns a new object, or a cached object in your own code.

 

answered by fhanik on January 7, 2013 04:55 PM

Read More

answer

27 comments   |  

0
Rating
  |  

Developers | JNDI, ObjectFactory, Tomcat Configuration

Ask the Experts : Apache Tomcat 7 Private byte increases and not releasing back

I have observed the tomcat 7 process memory (private bytes) was initially 1.2 GB during startup and it got increased to 3.5 GB where my server RAM size is only 4GB after running a 100 users test for 4 hours. this private bytes was not released even after stopping the test. could you please let us know any configurations that might help this or kindly analyze the situation and provide your suggestions/solutions.

Regards,

Raga

 

asked by Ragavendran

question

Lacking more specific about the behavior that you are seeing and about the environment that you are using to run your tests, and since this is a testing environment, my suggestion to you would be to run your tests while you have a profiler hooked up to Tomcat (YourKit is an excellent profiler).  The profiler will allow you to look for memory problems in your application.

That's not to say there is definitely a problem here.  It is entirely possible that you could see the heap grow from 1.2 G to 3.5G legitimately.  It just depends on your JVM options and the memory demands of your application.

answered by dmikusa on May 8, 2012 10:51 AM

Read More

answer

28 comments   |  

0
Rating
  |  

Developers, Executives | Tomcat Configuration, Tomcat Memory, YourKit

Ask the Experts : Tomcat-jdbc pooling not detecting dead connections

We recently migrated to using the apache tomcat jdbc connection pooling.

We are using v1.1.0.1 of the connection pooling mechanism with tomcat 6.0.33 on Oracle 10g

Our connection pools are configured as follows:

asked by san9jay

question

add

testOnBorrow="true"

validationQuery="select 1 from dual"

in order to validate your connections

answered by fhanik on May 10, 2012 08:39 AM

Read More

answer

16 comments   |  

0
Rating
  |  

Developers | Tomcat Configuration, tomcat jdbc connection killed detection

Ask the Experts : Validation not triggering when deployed into Tomcat

asked by alex

question

hi Alex, welcome to the world of Java.

My recommendation is that you run without the security manager. It is inherently complex to, and it's not where you start as a beginner.

Before even consider running with the security manager turned on, you need to evaluate your requirements if you even need it. In my experience, 9 out of 10 companies will not need it as they secure the environments where Tomcat runs instead. In shared environments with untrusted parties, such as a shared hosting environment, the security manager comes in handy as it can protect against code.

So, to get started, turn off the security manager, and get your application fully working. The security manager is not a feature of Apache Tomcat, it's part of the Java Runtime Environment.

best

Filip

 

answered by fhanik on June 28, 2012 07:39 AM

Read More

answer

11 comments   |  

0
Rating
  |  

Developers |

Ask the Experts : Is Apache tomcat 6.0 and 7.0 are windowsserver 2008 64bit and vmware esx 5 compatible

Hello,

After lots of research, I cannot find the answer. Can you tell me if Apache tomcat 6.0 and 7.0 are windowsserver 2008 64bit and vmware esx 5 compatible?

Thank you

asked by Chris424

question

There is really no issue of compatibility between Tomcat and these products.  Tomcat 6 & 7 run on the JVM and will run just fine on any system which has a capable implementation of the JVM.

Given that Oracle releases a 64 bit version of the JVM for Windows, you should have no problem running Tomcat 6 or 7 on Windows Server 2008 64-bit.

As for VMware ESX5, you may want to take a look at this link [1].  It documents the best practices for running any Java application, Tomcat 6 & 7 included, on VMware virtualization.

[1] - http://www.vmware.com/resources/techresources/1087

 

answered by dmikusa on February 20, 2012 08:21 AM

Read More

answer

12 comments   |  

0
Rating
  |  

|

Ask the Experts : Null pointer in manager web app. Tomcat 6.0.14

I'm using Tomcat 6.0.14 as part of a cognos product installation. I'm following the installation guide. After installing the product and edit the configuration files, I need to deploy a war and a ear files using de Tomcat Manager application. Trying to log on as the System manager the server returns the following error:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

asked by Ucat

question

You need to upgrade your Tomcat version.  Besides the fact that 6.0.14 is incredibly old and missing many security fixes, it appears that this bug has been fixed.

From the link you posted:

">My post is actually a bug report. Not a question.
Those NPEs have been fixed in svn and will be in the next release. "

http://markmail.org/message/zalrgnbb7frvfwgj

answered by dmikusa on February 20, 2012 08:25 AM

Read More

answer

54 comments   |  

0
Rating
  |  

|

Ask the Experts : catalina.out log rotation

 

Hi,

I am interested in catalina.out log file rotation, I have an application where logging to catalina.out is very huge, say 0.5 MB / sec.

So I have written one script to handle this which is shown below.

 

# crontab -l | grep catalina

0,30 * * * * bash /catalina_log_handler.sh  >/dev/null 2>&1

 

# more /catalina_log_handler.sh

#!/bin/sh

CATLOC=/bin/cat

SEDLOC=/usr/bin/sed

asked by akshay_tomcat

question

The catalina.out file is created by a shell redirection, ex ">> catalina.out 2>&1".  This catches anything written to System.out and System.err and places it into the catalina.out file. 

Given this, a good way to rotate catalina.out is to alter the script to pipe the output to a log rotation script rather than directly to a file.  This will allow you to rotate the logs without restarting Tomcat and without copying the entire contents of the log to another file.

It's a pretty simple change to catalina.sh and it is described at this link.

    http://marc.info/?l=tomcat-user&m=105640876032532&w=2

 

answered by dmikusa on February 20, 2012 08:27 AM

Read More

answer

45 comments   |  

0
Rating
  |  

Developers | log rotation