[CONF] Apache Tomcat > Monitoring

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Monitoring 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 03:29 AM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink. Fix formatting and links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  Permalink to this page: https://cwiki.apache.org/confluence/x/eColBg   Table of Contents   
 
 
 
 Table of Contents 
 
 
 
 
 
 
 
 
exclude 
Table of Contents 
 
 
  
 
 
  Monitoring Tomcat Monitoring of a running Tomcat instance can be done in several ways, but observing a Tomcat instance via JMX beans will give you the best information available through standard interfaces (i.e. JMX). You can find information about connecting to Tomcat via JMX in the Tomcat Users' Guide. Rather than repeating that information here (which is mostly about configuration, connection, etc.), please go read the official documentation. ... Similar to the HeapMemoryUsage MXBean described above, this one will give you information about the "PermGen" heap generation. Depending upon your garbage collection and other memory settings, you might have different MXBeans under java.lang:type=MemoryPool with different names. You should inspect each one to determine if they would be useful for you to inspect. Tomcat Information  Version Warning   These JMX bean names are accurate for the current version of Tomcat 7 (7.0.37 at the time of this writing). If you are using a different version of Tomcat, you may have to adjust the names of the beans identified on this page.  Thread Usage 
 
  JMX Bean: Catalina:type=Executor,name=[executor name]   
Attributes: poolSize, activeCount  
 ... Not using an Executor 
 
  JMX Bean: Catalina: type=ThreadPool,name="[depends]"   
Attributes: maxThreads, connectionCount  
 This information is largely useless in Tomcat 7, as an Executor is always used and the data can be found there, while the ThreadPool has only initial configuration information: the real-time data is available from the Executor's MBean. Request Throughput 
 
  JMX Bean: Catalina:type=GlobalRequestProcessor,name="[depends]"   
  Attributes: bytesSent, bytesReceived, errorCount, maxTime, requestCount   
  Operations: resetCounters   
 Sessions 
 
  JMX Bean: Catalina:type=Manager,context=[context name],host=[hostname]   
Attributes: activeSessions, sessionCounter, expiredSessions  
 JNDI DataSource  
 
  JMX Bean: Catalina:type=DataSource,context=[context name],host=[hostname],class=javax.sql.DataSource,name="[JNDI name]"   
  Attributes: numActive, numIdle    
 ... Another way to watch a Tomcat application is to use an external monitoring tool.  MoSKito, is an open source solution by Anotheria, is a multi-purpose, non-invasive, interval-based monitoring system kit that collects, stores and provides instant analysis of a Tomcat application’s performance and behavior data. ... Other plug-in-based monitoring software like Nagios or Icinga may need some help interacting with Tomcat's JMXProxyServlet. tools/check_jmxproxy.pl is a Perl script that can be used with these tools to monitor Tomcat via the JMXProxyServlet. ...  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Go to page history 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
View page 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Stop watching space
• 
 
 
 
 
 
 
Manage notifications 
 
 
 
 
 
 
 
 
 
 
  
 
 
This message was sent by Atlassian Confluence 6.15.8  
 
 
  
 
 
 
 
 
 
 
 
 




[CONF] Apache Tomcat > Performance and Monitoring

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Performance and Monitoring 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 03:20 AM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink. Fix formatting and links. + Drop links to benchmark results articles. Those were 10+ years old.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  Permalink to this page: https://cwiki.apache.org/confluence/x/oColBg  Preface This is about Tomcat performance. 
 
  Tomcat Performance Concerns   
  How do I increase performance on Tomcat?   
 Other (non-exhaustive) notes: 
 
Stress test your webapp. You can do this via JMeter, siege, flood, and other tools. Google is your friend. 
Tweak your UNIX box! Look at ulimit and kernel parameters. 
Bad design will hurt performance. 
Look at JProbe, or OptimizeIt, or New Relic, or other profiling tools . Lots of people recommend these tools. This is not an endorsement for them, I just notice other people like themfor Java. 
 Questions 
 
 Is Tomcat faster than serving static HTML pages than Apache httpd?  
 Is there an application-specific comparison between Tomcat and Resin or other containers?  
 Is there a comprehensive, up-to-date, detailed benchmark comparing various servlet containers, including Tomcat?  
 How do I configure apache tomcat connectors for a heavy load site?  
 How do I make Tomcat start up faster?  
 Answers  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q1 
 
 
 
Q1 
 
 
  
 
 
 Is Tomcat faster than serving static HTML pages than Apache httpd?  Yes depending on how you tune it. And NO depending on how you tune it. Anything less starts a religious war. We recommend performing your own benchmarks and see for yourself. ...  Here's one comparing recent versions of Resin and Tomcat running AppFuse.  ...  Yes. Here's the most comprehensive and objective one we've found to date: Web Performance, Inc.'s comparison.  ...  
 
 
 
 Anchor 
 
 
  ...  
 
 
 
 
 
 
 
 
 
 
  
 
 
   
 
 
 
 
 
 
 
Q4 
 
 
 
Q4 
 
 
  
 
 
 How do I configure apache tomcat connectors for a heavy load site?  The following excellent article was written by Mladen Turk. He is a Developer and Consultant for JBoss Inc in Europe, where he is responsible for native integration. He is a long time commiter for Jakarta Tomcat Connectors, Apache Httpd and Apache Portable Runtime projects.  Fronting Tomcat with Apache or IIS - Best Practices  
 
 httphttps://people.apache.org/~mturk/docs/article/ftwai.html  
  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q5 
 
 
 
Q5 
 
 
  
 
 
 How do I make Tomcat start up faster?  See HowTo FasterStartUp 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Go to page history 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
View page 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Stop watching space
• 
 
 
 
 
 
 
Manage notifications 
 
 
 
 
 
 
 
 
 
 
  
 
 
This message was sent by Atlassian Confluence 6.15.8  
 
 
  
 
 
 
 
 
 
 
 
 




[CONF] Apache Tomcat > Security

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Security 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 03:07 AM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink. Fix formatting and links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  Permalink to this page: https://cwiki.apache.org/confluence/x/qyolBg  Preface This FAQ section provides help with some security-related issues. If you hear of a vulnerability or its exploitation, please see the security page. The Record There have been no public cases of damage done to a company, organization, or individual due to a Tomcat security issue. There have been no documented cases of data loss or application crashes caused by an intruder. While there have been numerous analyses conducted on Tomcat, partially because this is easy to do with Tomcat's source code openly available, there have been only theoretical vulnerabilities found. All of those were addressed even though there were no documented cases of actual exploitation of these vulnerabilities. ... 
 
There have been several reports of a compromise done via guess of the password of a user of the Manager web application. 
  There was once a bug that blindly clicking-trough the Windows installer configured a manager user with blank password (CVE-2009-3548). This was fixed by April 2010 (Tomcat 5.5.29, 6.0.24 and later are safe).   Please see "Security considerations" pages in Tomcat documentation (linked below) for a reference on how access to Management Applications in Tomcat should be secured.  
 
There have been several reports of compromises via vulnerabilities in 3-rd party web applications deployed on Tomcat. E.g. vulnerabilities in Apache Struts framework were a popular attack target several times in years 2013-2017. E.g. Equifax breach in year 2017. It is unknown whether Equifax has run their application on Tomcat, but there have been a number of similar compromise reports from Tomcat users. Those are not caused by a vulnerability in Tomcat. 
 ... Links 
 
Known vulnerabilitieshttp: https//tomcat.apache.org/security.html  
Security considerations (Tomcat documentation) - — Tomcat 9, Tomcat 8.5, Tomcat  87.0, Tomcat 7  
 Questions 
 
 How do I use OpenSSL to set up my own Certificate Authority (CA)?  
 Oh no! Port 8005 is available for anyone on localhost to shutdown my tomcat!  
 What about Tomcat running as root?  
 How do I force all my pages to run under HTTPS?  
 What is the default login for the manager and admin app?  
 How do I restrict access by ip address or remote host?  
 How do I use jsvc/procrun to run Tomcat on port 80 securely?  
 Has Tomcat's security been independently analyzed or audited?  
 How do I change the Server header in the response?  
 Why are passwords in plain text?  
 How can I restrict the list of ciphers used for HTTPS?  
 Which cipher suites should I use?  
 Answers  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q1 
 
 
 
Q1 
 
 
  
 
 
 How do I use OpenSSL to set up my own Certificate Authority (CA)?   Using OpenSSL to set up your own CA.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q2 
 
 
 
Q2 
 
 
  
 
 
 Oh no! Port 8005 is available for anyone on localhost to shutdown my tomcat!  See these 2 discussions. 
 
 Possible to switch off tcp/ip server shutdown?  
 Tomcat shutdown & security  
  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q3 
 
 
 
Q3 
 
 
  
 
 
 What about Tomcat running as root?  See these threads: 
 
 Tomcat as root and security issues  
  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q4 
 
 
 
Q4 
 
 
  
 
 
 How do I force all my pages to run under HTTPS?   Use security-constraint in web.xml.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q5 
 
 
 
Q5 
 
 
  
 
 
 What is the default login for the manager and admin app?  The admin and manager application do not provide a default login. Doing so would be a security flaw. You need to edit $CATALINA_HOME/conf/tomcat-users.xml file if you are using the default install. See Configuring Manager Application Access for details. Note that there exists malware that tries to guess the manager password. There was once a bug that blindly clicking-trough the Windows installer configured a manager user with blank password (CVE-2009-3548). This was fixed by April 2010 (Tomcat 5.5.29, 6.0.24 and later are safe).  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q6 
 
 
 
Q6 
 
 
  
 
 
 How do I restrict access by ip address or remote host?  By using the RemoteHostValve or RemoteAddrValve. Warning, these valves rely on accurate incoming ip addresses or hostnames. So they can fall victim to spoofing! See also RemoteIpValve. Valve Reference Link   
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q7 
 
 
 
Q7 
 
 
  
 
 
 How do I use jsvc/pro

[CONF] Apache Tomcat > Tomcat Versions

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Tomcat Versions 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 02:50 AM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink. Fix formatting and links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  Permalink to this page: https://cwiki.apache.org/confluence/x/CjElBg   Table of Contents   
 
 
 
 Table of Contents 
 
 
 
 
 
 
 
 
exclude 
Table of Contents 
 
 
  
 
 
  Overview This page provides a high-level view of each of the past, current and planned major Tomcat versions. ... The "Process" field in the following tables documents what development model is accepted by that project, either Review-Then-Commit or Commit-Then-Review. For RTC model the changes are first proposed in the STATUS.txt file in the root of the project and have to gain at least 3 "+1" votes before being applied. The project members have agreed on several exceptions from the RTC rule (documented below). ... 
 
Changes to the documentation (including Javadoc) are C-T-R. 
 Via http https://tomcat.markmail.org/thread/2fgydrrhn4qjye3r : 
 
Allow C-T-R for trivial fixes to English messages that are in resource files and those that are inline in the code. This includes typos and rephrasing, but does not include adding/removing message parameters. 
Allow C-T-R for any fixes for non-English resource files. The files must use 7-bit characters only. Other symbols must be escaped with \u, as does native2ascii. 
Require some indication in the commit message for code that usually is covered by RTC, that this commit was done using C-T-R rule. 
 Via http https://tomcat.markmail.org/thread/vwqvurietvliadjf : 
 
The versions that were moved to the archive are C-T-R.   
 ...  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Go to page history 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
View page 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Stop watching space
• 
 
 
 
 
 
 
Manage notifications 
 
 
 
 
 
 
 
 
 
 
  
 
 
This message was sent by Atlassian Confluence 6.15.8  
 
 
  
 
 
 
 
 
 
 
 
 




[CONF] Apache Tomcat > Tomcat User mailing list

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Tomcat User mailing list 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 02:58 AM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink. Fix formatting and links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  Permalink to this page: https://cwiki.apache.org/confluence/x/wiolBg  Preface The Tomcat user mailing list is for all your questions about how to use Tomcat. It is a high volume list! For those who can't handle that kind of traffic, you can also get it in digest form. ... Here are some links about how to use mailing lists and standard etiquette in using mailing lists. These links are not Tomcat specific! Please do not contact the author of these documents with questions. 
 
 Netiquette Guidelines (RFC 1855)  
 How To Ask Questions The Smart Way  
 ... 
 
 How do I subscribe?  
 Why won't people answer my question?  
 How do I unsubscribe?  
 Should I post to users or dev?  
 Answers  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q1 
 
 
 
Q1 
 
 
  
 
 
 How do I subscribe?  See the mailing list page. If you are unable to subscribe, it could be due to your e-mail system mangling your e-mail addresaddress. If you send an e-mail to the list owner to subscribe you to the list, be prepared to wait until the owner has an opportunity to add you to the list.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q2 
 
 
 
Q2 
 
 
  
 
 
 Why won't people answer my question?  It could be one of any of the following answers: ... 
 
"help" in the subject line (we know you need help by writing in the first place) 
plz or please in the subject line. We already know you need help. 
ALL CAPS IN THE SUBJECT LINE. (Sorry for anyone emailing from a mainframe) 
Do not place !! (more than 2!) in the subject line. The number of exclamation points has no relation to anyone's interest in answering the question. In fact - it has a higher chance at being ignored. 
Your e-mail has a return receipt. You don't need to know I got the message. 
Select posters who have consistently displayed no desire to research before posting a question. 
  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q3 
 
 
 
Q3 
 
 
  
 
 
 How do I unsubscribe?  See the mailing list page. If you are unable to unsubscribe, it could be due to your e-mail system mangling your e-mail address or you have subscribed under an alias. In that case, maybe this thread will help. If you send an e-mail to the list owner to remove you from the list, be prepared to continue receiving more e-mails from the lists until the owner has an opportunity to remove you from the list.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q4 
 
 
 
Q4 
 
 
  
 
 
 Should I post to users or dev?  tomcat-user is for user based questions for tomcat. That means anyone who is developing any type of software to be used with tomcat. ...  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Go to page history 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
View page 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Stop watching space
• 
 
 
 
 
 
 
Manage notifications 
 
 
 
 
 
 
 
 
 
 
  
 
 
This message was sent by Atlassian Confluence 6.15.8  
 
 
  
 
 
 
 
 
 
 
 
 




[CONF] Apache Tomcat > Troubleshooting and Diagnostics

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Troubleshooting and Diagnostics 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 02:54 AM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Improve formatting of Table of Contents.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  Troubleshooting and Diagnostics techniques.   Permalink to this page: https://cwiki.apache.org/confluence/x/yColBg   Troubleshooting and Diagnostics techniques.   Table of Contents   
 
 
 
 Table of Contents 
 
 
 
 
 
 
 
 
exclude 
Table of Contents 
 
 
  
 
 
  Techniques & Reference 
 
 How To: Capture a thread dump  
 How To: Capture a heap dump  
 How To: Examine a Stacktrace  
 How To: Configure Tomcat for debugging  
 FAQ: Developing  
 FAQ: Memory  
 Tomcat Memory Leak Protection  
 Notes on using JMX clients  
 ...  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Go to page history 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
View page 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Stop watching space
• 
 
 
 
 
 
 
Manage notifications 
 
 
 
 
 
 
 
 
 
 
  
 
 
This message was sent by Atlassian Confluence 6.15.8  
 
 
  
 
 
 
 
 
 
 
 
 




[CONF] Apache Tomcat > Windows

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Windows 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 02:45 AM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink. Fix formatting and links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  Permalink to this page: https://cwiki.apache.org/confluence/x/3SolBg  Preface This page addresses various issues related to running Tomcat on a Windows platform. Please see the UsefulLinks for more links related to Windows. ... 
 
 Why do I get Out of Environment Space?  
 When I start up tomcat (or when it is running), I get the error java.lang.IllegalMonitorStateException: current thread not owner  
 Can I turn off case sensitivity?  
 Can I use NTLM authentication?  
 I want to redeploy web applications, how do I prevent resources from getting locked?  
 Can I use UNC paths?  
 Why can't Tomcat see my mapped drive when running as a service?  
 Why aren't access logs showing up in Tomcat on Vista?  
 Why do I get a "HTTP/1.x 400 No Host matches server name" error when I change the "webapps" folder in Tomcat on Vista?  
 How do I add or customize a Windows Service for Tomcat?  
 What are tomcat6wtomcat9w.exe/tomcat6tomcat9.exe (or tomcat7w.exe/tomcat7.exe etc..) ?  
 Answers  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q1 
 
 
 
Q1 
 
 
  
 
 
 Why do I get Out of Environment Space?  Check the Tomcat README, and this link   
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q2 
 
 
 
Q2 
 
 
  
 
 
 When I start up tomcat (or when it is running), I get the error java.lang.IllegalMonitorStateException: current thread not owner  That weird issue was observed many years ago and now is a history. See the Tomcat Bug Report #13723 and Sun Bug Parade report #4776385 for the answer.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q3 
 
 
 
Q3 
 
 
  
 
 
 Can I turn off case sensitivity?  It is possible in Tomcat 6 and earlier, but not recommended.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q4 
 
 
 
Q4 
 
 
  
 
 
 Can I use NTLM authentication?  Yes. 
 
 Waffle/JNA (obsolete)  
 Tomcat SPNEGO (obsolete)  
 SPNEGO SF  
 Jespa (commercial) 
 Tomcat IIS Connector  
 Samba JCIFs (obsolete, no NTLMv2) 
  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q5 
 
 
 
Q5 
 
 
  
 
 
 I want to redeploy web applications, how do I prevent resources from getting locked?  Most locking issues will occur with JARs from /WEB-INF/lib, and are usually caused by access through URLs. Tomcat has mechanisms to allow avoiding locking. Since Tomcat 5.0, a mechanism exists to prevent locking when accessing resources using the getResource method of the URLClassLoader. Many applications, such as Xerces, do not set the use of caching to false before opening the URL connection to a JAR file, and that causes locking. In Tomcat 5.5, this mechanism is disabled by default (as it has a non negligible influence on startup times, and is often useless), and can be enabled using the antiJARLocking attribute of the Context element. If getResource call occurs, resources inside the JARs will be extracted to the work directory of the web application. There is an alternative to this since Tomcat 6.0.24: you can configure a JreMemoryLeakPreventionListener in your server.xml and it will set the URL connection caching to be off by default. There is another lock prevention mechanism in Tomcat 5.5 (antiResourceLocking attribute), which will cause the web application files to be copied to the temp folder and run from this location. This has a larger impact on web application startup times, but obviously prevents locking on all resources of the web application. This also allows more flexible management operations as none of the web application resources will be locked, even while the web application is running (as a special note, when making changes to JSPs without reloading the application, the changes have to be duplicated to the path where the web application resources have been copied in the temp folder).  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q6 
 
 
 
Q6 
 
 
  
 
 
 Can I use UNC paths?  Yes. Make sure that the user that Tomcat is running as is able to access the path. This is particularly important when running Tomcat as a service since the local service account will not have the necessary permissions.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q7 
 
 
 
Q7 
 
 
  
 
 
 Why can't Tomcat see my mapped drive when running as a service?  The mapped drives are part of a user's profile and they are not used when running as a service. You should be OK with UNC paths.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q8 
 
 
 
Q8 
 
 
  
 
 
 Why aren't access logs showing up in Tomcat on Vista?  By default, the Tomcat Windows Service installer attempts to pla

[CONF] Apache Tomcat > Memory

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Memory 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 01:00 AM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink. Fix formatting and links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  tocPermalink to this page: https://cwiki.apache.org/confluence/x/RSolBg  Preface This page discusses various memory issues. In a nutshell - if your computer has less than 128MB of ram - you will probably have trouble. Anyhow, also read the following threads for other memory related issues: 
 
 java.lang.OutOfMemoryError during deploy  
 Memory requirements  
 Memory Mgmt Tomcat  
 Tomcat Out of memory  
 Tracking memory usage over time  
 Also look at YourKit, or maybe you IDE has a profiling tool in it, or other profiling tools are available. (The following tools were recommended by many people in the past, but now seem to be discontinued by their vendors: JProbe by Quest Software — the company was acquired by Dell, OptimizeIt by Borland). This is not an endorsement for them, I just notice other people like them. ... 
 
 How do I adjust memory settings?  
 Why do I get OutOfMemoryError errors?  
 How much memory is Tomcat/webapp/??? using?  
 Answers  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q1 
 
 
 
Q1 
 
 
  
 
 
 How do I adjust memory settings?  First look at java -X to determine what parameters to set. Then you can set them via the environment variable CATALINA_OPTS (using JAVA_OPTS also works, but is not recommended). This variable is usually set in a file bin/setenv.sh or bin/setenv.bat that you may need to create by yourselves. The setenv file is documented in RUNNING.txt in your version of Tomcat. The environment variables are described in a comment at the top of catalina.bat or catalina.sh files.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q2 
 
 
 
Q2 
 
 
  
 
 
 Why do I get OutOfMemoryError errors?  Many reasons. 
 
You're out of memory. Simple as that - add more to your heap. 
You're out of memory. You have code which is hanging onto object references and the garbage collector can't do its job. Get a profiler to debug this one. 
You ran out of file descriptors. If you are on a *nix system, it has been observed that an OutOfMemoryError can be thrown if you run out of file descriptors. This can occur if your threshold is too low. The ulimit program can help you out here. You also may need to account for socket connections too when thinking about these thresholds. Google is your friend for getting more information about this topic. 
You have too many threads running. Some OS's have a limit to the number of threads which may be executed by a single process. (Which is what the JVM is.) Refer to your OS docs for more information on how to raise this threshold. 
If you have a lot of servlets or JSP's, you may need to increase your permanent generation. By default, it is 64MB. Quadrupling it to be -XX:MaxPermSize=256m might be a good start. 
Your OS limits the amount of memory your process may take. OK, this one is grasping at straws. 
The JVM has a bug. This has been known to happen with JVM1.2.? and using EJB's with another servlet engine. 
Not actually a reason - but on your particular platform, look at the java -X options. They may be VERY helpful. 
 Your classloaders are not being garbage collected. 
You run out of process memory (non java/GC memory), for example when using java.util.zip classes or JNI classes allocating process memory. See Instantiating Inflater/Deflater causes OutOfMemoryError; finalizers not called promptly enough  
 See also OutOfMemory and MemoryLeakProtection.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q3 
 
 
 
Q3 
 
 
  
 
 
 How much memory is Tomcat/webapp/??? using?  
 
To find out how much memory Tomcat is using, you might be able to use the Runtime class provided by the JDK. 
You can't find out how much memory a webapp is using. The JVM doesn't give us these detail. 
You can't find out how much memory a ??? is using. The JVM doesn't give us these detail. 
That being said, a memory profiling tool might prove the above statements wrong - but you probably don't want to use them in a production environment. 
 ...  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Go to page history 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
View page 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Stop watching space
• 
 
 
 
 
 
 
Manage notifications 
 
 
 
 
 
 
 
 
 
 
  
 
 
This message was sent by Atlassian Confluence 6.15.8  
 
 
  
 
 
 
 
 
 
 
 
 




[CONF] Apache Tomcat > About

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
About 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 01:02 AM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink. Fix formatting and links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  Permalink to this page: https://cwiki.apache.org/confluence/x/gCklBg  Preface This FAQ is maintained by the Tomcat Committers. The content for this FAQ is usually discovered by lurking in the tomcat-user list. If you wish to make a comment about the FAQ, make the comment on the tomcat-user list. Do not e-mail any of the committers directly and do not e-mail the tomcat-dev list. (Unless other people liked your suggestion and it was accidentally missed by the committers who read the tomcat-user list) Emailing the tomcat-user list will allow a larger audience to immediately learn and critique your findings. ... 
 
 How did Tomcat get its name?  
 How do I contribute a question?  
 Answers  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q1 
 
 
 
Q1 
 
 
  
 
 
 How did Tomcat get its name?  He (James Duncan Davidson) came up with "Tomcat" since the animal represented something that could take care of itself and fend for itself. That's how he came up with the name.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q2 
 
 
 
Q2 
 
 
  
 
 
 How do I contribute a question?  
 
Make sure the question has been asked more than once 
Make sure the answer(s) given are correct 
Select the right FAQ section in Confluence 
Edit Confluence, keeping to the existing format and layout 
Add your question to the list at the start of the page 
Don't forget to add an anchor to the start of your answer 
 ...  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Go to page history 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
View page 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Stop watching space
• 
 
 
 
 
 
 
Manage notifications 
 
 
 
 
 
 
 
 
 
 
  
 
 
This message was sent by Atlassian Confluence 6.15.8  
 
 
  
 
 
 
 
 
 
 
 
 




[CONF] Apache Tomcat > Logging

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Logging 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 12:53 AM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink. Fix formatting and links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  Permalink to this page: https://cwiki.apache.org/confluence/x/KiolBg  Preface This FAQ section provides help with logging-related issues. ... 
 
 Does Tomcat have built-in logging capabilities, and if so how do I use them?  
 What role does commons-logging play in logging?  
 What role does JULI and log4j play in logging?  
 How do I configure commons-logging for use with Tomcat?  
 How should I log in my own webapps?  
 Where does System.out go?  
 How do I rotate catalina.out? 
 Where are the logs when running Tomcat as a Windows service?  
 How do I customize the location of the tomcat logging.properties file?  
 Since java.logging is the default commons-logging implementation in Tomcat, why is it not working in my Linux distribution?  
 Answers  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q1 
 
 
 
Q1 
 
 
  
 
 
 Does Tomcat have built-in logging capabilities, and if so how do I use them?  The Servlet Specification requires Servlet Containers like Tomcat to provide at least a rudimentary implementation of the ServletContext#log method. Tomcat provides a much richer implementation than required by the Spec, as follows: 
 
Prior to Tomcat 5.5, Tomcat provided a Logger element that you could configure and extend according to your needs. 
Starting with Tomcat 5.5, Logger was removed and Apache Commons-Logging Log is used everywhere in Tomcat. Read the Commons-Logging documentation if you'd like to know how to better use and configure Tomcat's internal logging. See also httphttps://tomcat.apache.org/tomcat-89.0-doc/logging.html  
In Tomcat 7 (and also 6), the logging code is based on a set of classes interacting with the java.util.logging API (JUL), which comes with Java since version 1.4. The Tomcat startup script configures the JVM to use a web-application-aware implementation of the JUL LogManager. This Tomcat logging infrastructure is called JULI, and one can still distinguish its Apache Commons Logging heritage, but the complex configuration has been edited out and the package name changed. 
 Web applications can get logging service by using the Servlet API logging (which not recommended), the JUL interface (which ultimately goes to JULI) or any other preferred interface for which they furnish the jar files and the appropriate configuration (see the respective descriptions for Log4J, SLF4J, logback or Apache Commons Logging for example). To additionally log information about requests going to the web application, "Valves" can be configured in the server.xml file, as described in detail here. For example, inside the  tag: 
 
 
 
 Code Block 
 
 
 
 
 
 
 
 
language 
xml 
 
 
  
 
 
 
 
 


  
 
 
 ... 
 
 
 
   
 
 
  This will produce a log file for each day, such as logs/localhost_access_log.2008-03-10.log, containing the files requested, IP address of the requester, and similar information.  
 
 
 
 No Format 
 
 
 
 
 
128.34.123.121 - - [10/Mar/2008:15:55:57 -0500] "GET /upload/ClickPoints.jsp HTTP/1.1" 200 
  
 
 
 ... 
 
 
 
 
2725 
  
 
 
 In addition, Tomcat does not swallow the System.out and System.err JVM output streams. You may use these streams for elementary logging if you wish, but a more robust approach such as commons-logging or Log4J is recommended for production applications.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q2 
 
 
 
Q2 
 
 
  
 
 
 What role does commons-logging play in logging?  Tomcat wants to support multiple logging implementations, so it uses commons-logging. In case that's unclear, think of it like this. You are a Tomcat developer. The car you drive when logging is the commons-logging car. The engine of that car is either JULI or log4j. Without one of these engines, the car goes no where. However regardless of whether you use JULI or log4j, the steering wheel, break, gas pedal, etc. are the same. Related FAQ: What role does JULI and log4j play in logging?   
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q3 
 
 
 
Q3 
 
 
  
 
 
 What role does JULI and log4j play in logging?  First see: What role does commons-logging play in logging?  Note in addition that in your own applications you could log directly with JULI or log4j. But once you choose one, you can't easily switch to the other later. If you use commons-logging you can.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q4 
 
 
 
Q4 
 
 
  
 
 
 How do I configure commons-logging for use with Tomcat?  You need to specify a commons-logging configuration file and, i

[CONF] Apache Tomcat > Linux Unix

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Linux Unix 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 12:33 AM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink. Fix formatting and links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  Permalink to this page: https://cwiki.apache.org/confluence/x/HSolBg  Preface Questions 
 
 I have Tomcat x.y.z installed as part of my OS. Is it good to use?  
 When I run ps (on Linux), why do I see my java process a bazillion times!  
 How do I run without an X server and still get graphics?  
 Tomcat dies after I log out!  
  Catalina.log contains : "SEVERE: StandardServer.await: create[8005] : Throwable occurred: java.net.BindException: The socket name is not available on this system.   
  Examples web application does not start. A ClassNotFoundException occurs.   
 Answers  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q5 
 
 
 
Q5 
 
 
  
 
 
 I have Tomcat x.y.z installed as part of my OS. Is it good to use?  Many Linux distributions provide a pre-packaged version of Apache Tomcat. These packages work fine and are easy to install for a normal single-instance case, but they make it more difficult for more specific use cases, and more difficult for people on the Tomcat User mailing list to help you. That is because each of these packages distributes the files of Tomcat in different places on the disk, sets different environment variables, sets different links from one directory to the other in the filesystem, etc.. Moreover, some of those packages are notably outdated. So it would be better to install a "standard" tomcat downloaded from the website http https://tomcat.apache.org/, to some directory like /opt/tomcat, and follow the instructions that are given in the "RUNNING.txt" file. ... 
 
Download a "binary" version. There is usually no need to re-compile Tomcat from the source code. 
Either a "tar.gz" or a "zip" file is fine. The "tar.gz" files use GNU extensions to the tar file format (as mentioned in "README" file in the download area). You need a GNU-compatible version of tar to unpack them. 
Learn how to run Tomcat with separate values of CATALINA_HOME and CATALINA_BASE, as explained in "RUNNING.txt". This will simplify further upgrades and maintenance. 
  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q1 
 
 
 
Q1 
 
 
  
 
 
 When I run ps (on Linux), why do I see my java process a bazillion times!  Linux implemented threads as processes. Due to other gory details that is beyond the scope of this FAQ - the ps command doesn't work correctly with respect to threads. You can get more gory details here and here .   
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q2 
 
 
 
Q2 
 
 
  
 
 
 How do I run without an X server and still get graphics?  You either need to run headless or run an alternate X-server. Some more information can be found here, here, or here. Or if your are using a JVM 1.4 or better, you can use the system property java.awt.headless=true   
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q3 
 
 
 
Q3 
 
 
  
 
 
 Tomcat dies after I log out!  This is a common complaint when using Solaris. Make sure you use nohup and see this thread   
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q4 
 
 
 
Q4 
 
 
  
 
 
  ...  Error message: "SEVERE:  ...   StandardServer.await: create[8005]: Throwable occurred: java.net.BindException: The socket name is not available on this system."  This error message can have 2 causes: 
 
Java on AIX isn't supporting IPv6 properly. Fix by inserting -Djava.net.preferIPv4Stack=true into JAVA_OPTS 2.   
Your networking configuration is not correct. If you attempt to ping localhost and don't see 127.0.0.1 you need to look into your /etc/host.conf (most Unixes/Linux) or /etc/netsvc.conf (AIX) file to ensure that something like "hosts = local, bind" is present. 
  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q6 
 
 
 
Q6 
 
 
  
 
 
 Examples web application does not start. A ClassNotFoundException occurs.  Go into webapps/examples/WEB-INF/classes and check whether the class file mentioned in the error message does exist. If you downloaded a tar.gz file and used a non-GNU version of tar (e.g. on Solaris) it may use wrong (truncated) file names on files that are deep in the hierarchy. This occurs silently: there may be no error or warning during unpacking. One place that is known to suffer from this is the examples web application. The workaround is to download a "zip" file instead of a "tar.gz" one. thread 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Go to page history 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
View page 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Stop watching space
• 
 
 
 
 
 
 

[CONF] Apache Tomcat > KnownIssues

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 2 new edits on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
KnownIssues 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comments 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 12:24 AM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Corrected formatting.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 12:23 AM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink. Fix formatting and links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
 FAQ / Known Issues  Permalink to this page: https://cwiki.apache.org/confluence/x/DColBg  Questions 
 
 What are the known issues in any given Tomcat version?  
 What are the known issues with the Oracle JRE?  
 What are the known issues with the OpenJDK?  
 I'm using the Java ImageIO to dynamically serve images and get strange Exceptions from time to time. Is this a bug in Tomcat?  
 Answers  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
TomcatIssues 
 
 
 
TomcatIssues 
 
 
  
 
 
 What are the known issues in any given Tomcat version?  To determine the known issues for any given Tomcat version, you'll need to review the following: ... See chapter Looking for known issues on Tomcat web site.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
OracleJREIssues 
 
 
 
OracleJREIssues 
 
 
  
 
 
 What are the known issues with the Oracle JRE?  
 
 jps.exe and jvisualvm.exe cannot detect tomcat using jdk1.6.0_23 onwards — Fixed in Java 1.6.0_25. 
  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
OpenJDKIssues 
 
 
 
OpenJDKIssues 
 
 
  
 
 
 What are the known issues with the OpenJDK?  
 
There have been reports that java.util.logging does not work properly in OpenJDK 1.7.0.9 and OpenJDK6 1.6.0_32. The symptom is "java.lang.ClassNotFoundException: 1catalina.org.apache.juli.FileHandler" errors when you start Tomcat. See these threads from March 2013 and July 2013. This issue was absent in earlier versions and should be fixed in a later version of those JDKs. 
  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
ImageIOIssues 
 
 
 
ImageIOIssues 
 
 
  
 
 
 I'm using the Java ImageIO to dynamically serve images and get strange Exceptions from time to time. Is this a bug in Tomcat?  Imagine you have a servlet which dynamically generates images and serves them via javax.imageio.ImageIO. To write the image to the OutputStream, perhaps you are doing something like this: 
 
 
 
 Code Block 
 
 
 
 
 
 
 
 
language 
java 
 
 
  
 
 
 
 
 
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
BufferedImage img = createMyImage(); // makes a BufferedImage

response.setContentType("image/png");
try (OutputStream out = response.getOutputStream()) { // try-with-resources
ImageIO.write(img, "PNG", out);
} catch (IOException ex) {
// Client aborted connection
}
}
  
 
 
 Now, although there shouldn't be any Exception logged (because the IOException which occurs when the client aborted the connection is ignored), you see strange Exceptions in Tomcat's log which may belong to other Servlets/JSP (at least with Sun/Oracle JVM on Windows), saying that the response has already been committed, although you didn't write anything to it at that time. For example: 
 
 
 
 No Format 
 
 
 
 
 

13.07.2011 00:13:51 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [myApp.MyServlet] in context with path [] threw exception
java.lang.IllegalStateException: Cannot create a session after the response has been committed
	at org.apache.catalina.connector.Request.doGetSession(Request.java:2734)
...
  
 
 
 or maybe you use the ISAPI Redirector for IIS on Windows, and get these logs: 
 
 
 
 No Format 
 
 
 
 
 
[Tue Jul 12 06:04:49.812 2011] [4124:2444] [error] ajp_connection_tcp_get_message::jk_ajp_common.c (1296): wrong message format 0xdaed from 127.0.0.1:8019
  
 
 
  Is this a bug in Tomcat?  Actually, it's a bug (or at least a strange behavior) in the Java ImageIO. When the ImageIO writes to an OutputStream and gets an IOException during writing, it could happen that some later time, when the ImageWriter is garbage-collected, the flush() method is called on that OutputStream. Tomcat recycles OutputStream objects to save resources, so it could be that when flush() is called from the ImageIO, the particular OutputStream object already belongs to another Response, which can produce the above errors, when the Servlet tries to get a Session for example, or can generally lead to broken responses. See also here or this Bug report.  So how to resolve the errors?  To resolve this, I'm using an OutputStream decorator class which decorates Tomcat's Out

[CONF] Apache Tomcat > HowTo

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
HowTo 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 12:09 AM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Fix formatting and links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
 ... Download the source bundle or grab the source files from Tomcat Git repository (at GitHub). The docs are in the webapps/docs subdirectory. They are in XML format and get processed into the HTML documentation as part of the Tomcat release. ... The best way is to use jsvc, available as part of the commons-daemon Apache Commons Daemon project. ...  One Other way is to put Apache httpd with mod_jk before your Tomcat servers, and use ports >=1024 in the Tomcat(s). However, if httpd is not needed for some other reason, this is the most inefficient approach. ...  Another An other method is to use SetUID scripts (assuming you have the capability) to do this. Here's how I do it. ... There are some other methods available, like using ServletContext.getContextPath() to get the context name of your web application and locate some resources accordingly, or to define  elements in WEB-INF/web.xml file of your web application and then set the values for them in Tomcat context file (META-INF/context.xml). See https://tomcat.apache.org/tomcat-79.0-doc/config/context.html . How do I configure Tomcat Connectors? ... How do I enable Server Side Includes (SSI)? See http https://tomcat.apache.org/tomcat-7.0-doc/ssi-howto.html  How do I install the Administration web app? ... 
 
Add a line to your c:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\tomcat-users.xml file so that you have a user who has admin role. For example, add this line just before the last line (containing ) of the file: 
 
 
  
Restart Tomcat. 
Now when you visit _http://localhost:8080/admin_ you should see a page that asks for a user name and password. If you still see the "no longer loaded" error message in your browser, you must either force a full reload of the web page (in Firefox, hold down Shift key while clicking on the Reload button) or just restart your browser completely. 
 ... If you start Tomcat by using the standard script files (such as CATALINA_HOME/bin/catalina.bat or catalina.sh), this can be done by setting CATALINA_OPTS environment variable. The recommended way to do so is to create a setenv.bat or setenv.sh file, — read RUNNING.txt for details. Let say you want to increase it to 256 MB (as you required but make sure you have enough amount of physical memory/RAM and for 32bit system, use no more than 1.0-1.1 GB heap space size ). Set the CATALINA_OPTS to the value of -Xms256m -Xmx256m. In some cases it is better to set slightly lower size for -Xms. ... This is simply telling, that the items "jms/MyQCF", and "jms/MyQ" exist, and are instances of QueueConnectionFactory, and Queue, respectively. The actual configuration is in context.xml: ... Tomcat Manager web application starting with Tomcat 7.0.58 / 8.0.0 supports a command that outputs a thread dump. (Tomcat 9 documentation, BZ 57261)  StuckThreadDetectionValve valve logs stacktraces of request processing threads that are busy for longer than configured time limit. It is available starting with Tomcat 6.0.36 / 7.0.14. (Tomcat 9 documentation) ... 3. Build your ContextListener: According to the Tomcat's documentation, a Listener is a a component that performs actions when specific events occur, usually Tomcat starting or Tomcat stopping.. We need to instantiate and load our MBean at Tomcat's start. So we build a ContextListener.java file which is placed wherever you want in your project architecture: ...  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Go to page history 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
View page 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Stop watching space
• 
 
 
 
 
 
 
Manage notifications 
 
 
 
 
 
 
 
 
 
 
  
 
 
This message was sent by Atlassian Confluence 6.15.8  
 
 
  
 
 
 
 
 
 
 
 
 




[CONF] Apache Tomcat > HowTo

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 2 new edits on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
HowTo 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comments 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 11:56 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Fix formatting and links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 11:50 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Fix formatting and links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
 ... This is simply telling, that the items "jms/MyQCF", and "jms/MyQ" exist, and are instances of QueueConnectionFactory, and Queue, respectively. The actual configuration is in context.xml: ... Thus, if you have JNI code that follows the convention of including a static initilaizer like this: 
 
 
 
 No Format 
 
 
 
 
 

class FooWrapper {
static {
System.loadLibrary("foo");
}

native void doFoo();
  }
  
 
 
 then both this class and the shared library should be placed in the $CATALINA_HOME/shared/lib directory. ... The symptom of this problem that I encountered looked something like this - 
 
 
 
 No Format 
 
 
 
 
 

java.lang.UnsatisfiedLinkError: Native Library WEB-INF/lib/libfoo.so already loaded in another classloader
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1525)
  
 
 
 ... 
 
If you have not already done so begin by creating a new Tomcat context for your application. Navigate to TOMCAT_HOME\conf\Catalina\localhost and create a new file, say, myapp.xml. This will become part of your url, so to access your app you'll have to type *http://localhost:8080/myapp*. 
Enter the following in myapp.xml: 
 
 
 
 
 No Format 
 
 
 
 
 


  
 
 
 
 
This assumes you have a web application containing WEB-INF in c:/workspace/myapp/WebRoot  
Create two environment variables: 
 
 
 
 
 No Format 
 
 
 
 
 

C:\>set JPDA_ADDRESS=1044
C:\>set JPDA_TRANSPORT=dt_socket
  
 
 
 
 
Now, you can launch Tomcat with these debug options: 
 
 
 
 
 No Format 
 
 
 
 
 

TOMCAT_HOME\bin\>catalina jpda start
  
 
 
 
 
Use your IDE to connect to Tomcat through port 1044 
 See also: FAQ/Developing  How do I debug a Tomcat application when Tomcat is run as a Windows service ? ... 
 
Launch a command prompt 
Set the proper CATALINA_HOME environment variable: pointing to tomcat home 
Run the following command: 
 
 
 
 
 No Format 
 
 
 
 
 

%CATALINA_HOME%\bin\tomcat6w.exe //ES//tomcat6
  
 
 
 
 
Select the Java tab in the properties dialog box, 
Add the following two lines to the Java Options text box: 
 
 
 
 
 No Format 
 
 
 
 
 

-Xdebug
-Xrunjdwp:transport=dt_socket,address=127.0.0.1:1044,server=y,suspend=n
  
 
 
 ... For IntelliJ IDEA you choose a remote debug target and set transport to "socket" and mode to "attach" , then you specify the host (127.0.0.1) and port (1044) See also: FAQ/Developing  How do I check whether Tomcat is UP or DOWN? There is no status command ... Here is my code to do this. Consider it public domain and use it as you see fit. Tomcat makes a note of this connection with something like this on the console. 
 
 
 
 No Format 
 
 
 
 
 

May 1, 2007 5:10:35 PM org.apache.catalina.core.StandardServer await
WARNING: StandardServer.await: Invalid command '' received
  
 
 
 Ideally this should be incorporated into org.apache.catalina.util.ServerInfo by some committer. In addition to the shutdown command they should add commands like status (UP or DOWN) and uptime in the await method of org.apache.catalina.core.StandardServer  
 
 
 
 No Format 
 
 
 
 
 

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;

/**
 * Check to see if Tomcat is UP/DOWN.
 *
 * This parses the server.xml file for the Tomcat admin port and see if
 * we can connect to it. If we can, then the Tomcat is UP otherwise it
 * is DOWN
 *
 * It is invoked as follows:
 *java -Dcatalina.base=c:/tomcat-6.0.10 CatalinaStatus
 *
 * It can also (optionally) shutdown the Tomcat by adding the shutdown
 * command line parameter as follows:
 *
 *java -Dcatalina.base=c:/tomcat-6.0.10 CatalinaStatus shutdown
 *
 * @author Shiraz Kanga 
 */
public class CatalinaStatus
{
  /**
   * Pathname to the server configuration file.
   */
  protected static String configFile = "conf/server.xml";
  protected static String serverShutdown;
  protected static int serverPort;

  /**
   * The application main program.
   *
   * @param args Command line arguments
   */
  public static void main (String args[])
  {
Document co

[CONF] Apache Tomcat > HowTo

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
HowTo 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 11:40 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Fix formatting and links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
 ... Here are the three most popular ways:: 
 
Use a classloader's getResource() method to get an url to the properties file and load it into the Properties. The properties file must be located within the webapp classpath (i.e. either WEB-INF/classes/... or in a jar in WEB-INF/lib/). 
  A challenge is to get the classloader when you are in a static initializer:  
 
 
 
 No Format 
 
 
 
 
   
 public class Config {
 private static java.util.Properties prop = new java.util.Properties();
 private static loadProperties() {
  // get class loader
  ClassLoader loader = Config.class.getClassLoader();
  if(loader==null)
loader = ClassLoader.getSystemClassLoader();

  // assuming you want to load application.properties located in WEB-INF/classes/conf/
  String propFile = "conf/application.properties";
  java.net.URL url = ""
  try{prop.load(url.openStream());}catch(Exception e){System.err.println("Could not load configuration file: " + propFile);}
 }

 //
 // add your methods here. prop is filled with the content of conf/application.properties

 // load the properties when class is accessed
 static {
loadProperties();
 }
  }
  
 
 
  This method even works in a standalone java application. So it is my preferred way.  ...  
 
Use a ResourceBundle. See the Java docs for the specifics of how the ResourceBundle class works. Using this method, the properties file must go into the WEB-INF/classes directory or in a jar file contained in the WEB-INF/lib directory. 
Another way is to use the method getResourceAsStream() from the ServletContext class. This allows you update the file without having to reload the webapp as required by the first method. Here is an example code snippet, without any error trapping: 
 
 
 
 
 No Format 
 
 
 
 
 

// Assuming you are in a Servlet extending HttpServlet
// This will look for a file called "/more/cowbell.properties" relative
// to your servlet Root Context
InputStream is = getServletContext().getResourceAsStream("/more/cowbell.properties");
Properties  p  = new Properties();
p.load(is);
is.close();
  
 
 
 ... You cannot share sessions directly across web apps, as that would be a violation of the Servlet Specification. There are workarounds, including using a singleton class loaded from the common classloader repository to hold shared information, or putting some of this shared information in a database or another data store. Some of these approaches have been discussed on the tomcat-user mailing list, whose archives you should search for more information. ... Here's what you would like to do, but it throws ClassCastException: 
 
 
 
 No Format 
 
 
 
 
 

MyPrincipal p = request.getUserPrincipal();
String emailAddress = p.getEmailAddress();
  
 
 
 Here are 4 ways you might get around the classloader boundary: 1) Reflection  
 
 
 
 No Format 
 
 
 
 
 

Principal p = request.getUserPrincipal();
String emailAddress = p.getClass().getMethod("getEmailAddress", null).invoke(p, null);
  
 
 
 ... Rather than move the implementing custom classes up, you could define interfaces for your customs classes, and put the interfaces in the common directory. You're code would look like this: 
 
 
 
 No Format 
 
 
 
 
 

public interface MyPrincipalInterface extends java.security.Principal {
  public String getEmailAddress();
}

public class MyPrincipal implements MyPrincipalInterface {
...
  public String getEmailAddress() {
return emailAddress;
  }
}

public class MyServlet implements Servlet {
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
MyPrincipalInterface p = (MyPrincipalInterface)request.getUserPrincipal();
String emailAddress = p.getEmailAddress();
...
}
  
 
 
 ... 4) Serializing / Deserializing  ...  You   ...   might   ...   want   ...   to   ...   try   ...   serializing   ...   the   ...   response   ...   of   ...  request.getUserPrincipal()  ...   and   ...   deserialize   ...   it   ...   to   ...   an   ...   instance   ...   of   ...  webapp's MyPrincipal.  How do I get direct access to a Tomcat Realm? Credit: This code is from a post by Yoav Shapira http https://www.yoavshapira.com/ in the user list Sometimes access directly into the Tomcat realm object is needed; to do, this the following code can be used. Be a

[CONF] Apache Tomcat > HowTo

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
HowTo 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 11:31 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Fix formatting and links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
 ... For other parameters, look at the following pages: 
 
 FAQ/Memory  
 OutOfMemory  
 If you are running Tomcat as a Windows service, then environment variables and setenv.bat script have no effect. The relevant settings for the service wrapper application are stored in the Windows registry. They can be edited via Configuration application (tomcatw.exe). See "Java" tab in the configuration dialog. The{{-Xms}} and -Xmx options are configured in fields named "Initial memory pool" and "Maximum memory pool". Other options can be added to "Java Options" field as if they were specified on the command line of java executable. ... Congratulations. You have created and tested a first web application (traditionally called "mywebapp"), users can access it via the URL "http://myhost.company.com/mywebapp". You are very proud and satisfied. But now, how do you change the setup, so that "mywebapp" gets called when the user enters the URL "http://myhost.company.com" ? ...  The   ...   pages   ...   and   ...   code   ...   of   ...   your   ...   "mywebapp"   ...   application   ...   currently   ...   reside   ...   in   ...   (CATALINA_BASE)/webapps/mywebapp/.   ...   In   ...   a   ...   standard   ...   Tomcat   ...   installation,   ...   you   ...   will   ...   notice   ...   that   ...   under   ...   the   ...   same   ...   directory   ...   (CATALINA_BASE)/webapps/,   ...   there   ...   is   ...   a   ...   directory   ...   called   ...  ROOT  ...   (the   ...   capitals   ...   are   ...   important,   ...   even   ...   under   ...   Windows).   ...   That   ...   is   ...   the   ...   residence   ...   of   ...   the   ...  current  ...   Tomcat   ...   default   ...   application,   ...   the   ...   one   ...   that   ...   is   ...   called   ...   right   ...   now   ...   when   ...   a   ...   user   ...   calls   ...   up   ...   "http://myhost.company.com  ...  [:port  ...  ]".   ...   The   ...   trick   ...   is   ...   to   ...   put   ...   your   ...   application   ...   in   ...   its   ...   place.  First stop Tomcat.Then before you replace the current default application, it may be a good idea to make a copy of it somewhere else.Then delete everything under the ROOT directory, and move everything that was previously under the (CATALINA_BASE)/webapps/mywebapp/ directory, toward this (CATALINA_BASE)/webapps/ROOT directory. In other words, what was previously .../mywebapp/WEB-INF should now be .../ROOT/WEB-INF (and not .../ROOT/mywebapp/WEB-INF). ... For more information about this topic in general, consult this page : "Configuration Reference / Context"   Addendum 2: If for some reason you want another method..  If, for some reason, you do not want to deploy your application under the CATALINA_BASE/webapps/ROOT subdirectory, or you do not want to name your war-file "ROOT.war", then read on. But you should first read this : "Configuration Reference / Context" and make sure you understand the implications. ...  Warning: The above recipe on how to obtain a Context for a web application is a bit obsolete and does not work in Tomcat 7 and later (as Server is no longer a singleton). There are other ways to achieve that. An easy one is to add a Valve or Listener to a context, as those classes have access to Tomcat internals. There may be other ways mentioned in the archives of the users mailing list. How do I redirect System.out and System.err to my web page? ... This is simply telling, that the items "jms/MyQCF", and "jms/MyQ" exist, and are instances of QueueConnectionFactory, and Queue, respectively. The actual configuration is in context.xml: ... Basically, you just have to enter your values for  (the WebSphere MQ servers host name),  (the channel name),  (the queue manager name), and  (the queue name). Both these values, the associated names (HOST, PORT, CHAN, ...), and their collection is truly MQ specific. For example, with ActiveMQ, you typically have a broker URL, and a broker name, rather than HOST, PORT, CHAN, ... The main thing to know (and the reason why I am writing this, because it took me some hours to find out): How do I know the property names, their meaning, and possible values? Well, there is an excellent manual, called "WebSphere MQ Using Java". It should be easy to find by entering the title into Google. The manual contains a section, called "Administering JMS objects", which describes the objects being

[CONF] Apache Tomcat > HowTo

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 3 new edits on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
HowTo 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comments 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 11:26 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Remove "how to configure a client certificate", a referenced web site no longer exists.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 11:23 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Change a Tomcat 7 link to point to Tomcat 9.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 11:21 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Convert links to https. Remove a broken link.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
 ... There are some other methods available, like using ServletContext.getContextPath() to get the context name of your web application and locate some resources accordingly, or to define  elements in WEB-INF/web.xml file of your web application and then set the values for them in Tomcat context file (META-INF/context.xml). See http https://tomcat.apache.org/tomcat-7.0-doc/config/context.html . How do I configure Tomcat Connectors? ... In particular, here are a number of locations for Tomcat Connectors: 
 
 Tomcat Connectors Documentation  
 Tomcat Connectors FAQ  
 Configuring Tomcat Connectors for Apache  
 Connectors How To  
 AJP Connector in Tomcat  7 9 Configuration Reference  
 The following excellent article was written by Mladen Turk. He is a Developer and Consultant for JBoss Inc in Europe, where he is responsible for native integration. He is a long time commiter for Jakarta Tomcat Connectors, Apache Httpd and Apache Portable Runtime projects. 
 
 Fronting Tomcat with Apache or IIS - Best Practices httphttps://people.apache.org/~mturk/docs/article/ftwai.html  
  John Turner has an excellent page about Using Apache HTTP with Apache Tomcat. Several Over the time several different connectors have been built, and some connector projects have been abandoned (so beware of old documentation). ... Setting up SSL Threads from the tomcat-user list  Using VeriSign: 
 
 httphttps://marc.info/?l=tomcat-user&m=106285452711698&w=2  
 httphttps://marc.info/?l=tomcat-user&m=107584265122914&w=2  
 Using OpenSSL: 
 
 httphttps://marc.info/?l=tomcat-user&m=106293430225790&w=2  
 httphttps://marc.info/?l=tomcat-user&m=106453566416102&w=2  
 httphttps://marc.info/?l=tomcat-user&m=106621232531781&w=2  
 A description of "what SSL is all about anyway": 
 
 httphttps://marc.info/?l=tomcat-user&m=106692394104667&w=2  
  HowTo SSL Client Authentication with Fallback to FORM Authentication  See SSLWithFORMFallback   How   ...  See http://java-notes.com/index.php/two-way-ssl-on-tomcat   How do I restrict the list of SSL ciphers used for HTTPS ... For other parameters, look at the following pages: 
 
 FAQ/Memory  
 OutOfMemory  
 If you are running Tomcat as a Windows service, then environment variables and setenv.bat script have no effect. The relevant settings for the service wrapper application are stored in the Windows registry. They can be edited via Configuration application (tomcatw.exe). See "Java" tab in the configuration dialog. The{{-Xms}} and -Xmx options are configured in fields named "Initial memory pool" and "Maximum memory pool". Other options can be added to "Java Options" field as if they were specified on the command line of java executable. ...  Warning: The above recipe on how to obtain a Context for a web application is a bit obsolete and does not work in Tomcat 7 and later (as Server is no longer a singleton). There are other ways to achieve that. An easy one is to add a Valve or Listener to a context, as those classes have access to Tomcat internals. There may be other ways mentioned in the archives of the users mailing list. How do I redirect System.out and System.err to my web page? ... This is simply telling, that the items "jms/MyQCF", and "jms/MyQ" exist, and are instances of QueueConnectionFactory, and Queue, respectively. The actual configuration is in context.xml: ... Basically, you just have to enter your values for  (the WebSphere MQ servers host name),  (the channel name),  (the queue manager name), and  (the queue name). Both these values, the associated names (HOST, PORT, CHAN, ...), and their collection is truly MQ specific. For example, with ActiveMQ, you typically have a broker URL, and a broker name, rather than HOST, PORT, CHAN, ... The main thing to know (and the reason why I am writing this, because it took me some hours to find out): How do I know the property names, their meaning, and possible values? Well, there is an excellent manual, called "WebSphere MQ Using Ja

[CONF] Apache Tomcat > HowTo

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
HowTo 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 11:13 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Fix formatting and broken links.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
 ... Honestly, the first question is "why are you rotating catalina.out"? Tomcat logs very little to catalina.out so the usual culprit is web applications that stupidly send output to System.out or System.err. If that's the case, what you ought to do is set swallowOutput="true" on the application's  configuration. That will send the output to a file configured (default) by conf/logging.properties. Once you've done that, get the application fixed to use a real logger, or at least use ServletContext.log(). If you've decided that you still absolutely positively need to rotate catalina.out, there is something that you have to understand: catalina.out is created by your shell's output redirection, just like when you type "ls -l > dir_listing.txt". So rotating the file needs to be done carefully. ... Rotate catalina.out using logrotate (or similar) ...  To   ...   use   ...   a   ...   tool   ...   like   ...  logrotate  ...  ,   ...   you'll   ...   want   ...   to   ...   use   ...   the   ...   "copytruncate"   ...   configuration   ...   option.   ...   This   ...   will   ...   copy   ...   catalina.out   ...   to   ...   another   ...   file   ...   (like   ...   catalina.out.  ...  datestamp  ...  )   ...   and   ...   then   ...   truncates   ...   catalina.out   ...   to   ...   zero-bytes.   ...   There   ...   is   ...   a   ...   major   ...   downside   ...   to   ...   this   ...   if   ...   catalina.out   ...   is   ...   seeing   ...   a   ...   lot   ...   of   ...   action:   ...   some   ...   log   ...   messages   ...   written   ...   to   ...   the   ...   log   ...   file   ...   during   ...   the   ...   copy/truncate   ...   procedure   ...   may   ...   be   ...   lost.  Rotate catalina.out using rotatelogs or chronolog (or similar) To use a tool like Apache httpd's rotatelogs or chronolog, you'll have to modify Tomcat's catalina.sh (or catalina.bat) script to change the output redirection from a redirect to a pipe. The existing code in catalina.sh looks like this: 
 
 
 
 No Format 
 
 
 
 
 
 eval "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
  -Djava.endorsed.dirs="\"$JAVA_ENDORSED_DIRS\"" -classpath "\"$CLASSPATH\"" \
  -Djava.security.manager \
  -Djava.security.policy=="\"$CATALINA_BASE/conf/catalina.policy\"" \
  -Dcatalina.base="\"$CATALINA_BASE\"" \
  -Dcatalina.home="\"$CATALINA_HOME\"" \
  -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
  org.apache.catalina.startup.Bootstrap "$@" start \
  >> "$CATALINA_OUT" 2>&1 "&"
  
 
 
 You'll need to change that to something which looks more like this: 
 
 
 
 No Format 
 
 
 
 
 
 eval "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
  -Djava.endorsed.dirs="\"$JAVA_ENDORSED_DIRS\"" -classpath "\"$CLASSPATH\"" \
  -Djava.security.manager \
  -Djava.security.policy=="\"$CATALINA_BASE/conf/catalina.policy\"" \
  -Dcatalina.base="\"$CATALINA_BASE\"" \
  -Dcatalina.home="\"$CATALINA_HOME\"" \
  -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
  org.apache.catalina.startup.Bootstrap "$@" start \
  | "$PATH_TO_CHRONOLOG" $CATALINA_BASE/logs/catalina.out.%Y-%m-%d
  
 
 
 ... For other parameters, look at the following pages: 
 
 FAQ/Memory  
 OutOfMemory  
 If you are running Tomcat as a Windows service, then environment variables and setenv.bat script have no effect. The relevant settings for the service wrapper application are stored in the Windows registry. They can be edited via Configuration application (tomcatw.exe). See "Java" tab in the configuration dialog. The{{-Xms}} and -Xmx options are configured in fields named "Initial memory pool" and "Maximum memory pool". Other options can be added to "Java Options" field as if they were specified on the command line of java executable. ...  Warning: The above recipe on how to obtain a Context for a web application is a bit obsolete and does not work in Tomcat 7 and later (as Server is no longer a singleton). There are other ways to achieve that. An easy one is to add a Valve or Listener to a context, as those classes have access to Tomcat internals. There may be other ways mentioned in the archives of the users mailing list. How do I redirect System.out and System.err to my web page? ... This is simply telling, that the items "jms/MyQCF", and "jms/MyQ" exist, and are instances of Que

[CONF] Apache Tomcat > HowTo

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
HowTo 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 11:03 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Fix formatting. Remove a broken link.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
 ... Another method is to use SetUID scripts (assuming you have the capability) to do this. Here's how I do it. Create a file called foo.c with this content (replace "/path/startupscript" with the tomcat startup script): 
 
 
 
 Code Block 
 
 
 
 
 
 
 
 
language 
cpp 
 
 
title 
foo.c 
 
 
  
 
 
 
 
 
#include 
#include 
  
 
 
 ... 
 
 
 
 Wiki Markup 
 
 
 
 
 

int main( int argc, char \*argv\[\] ) \{
  if ( setuid( 0 ) != 0 ) {
perror( "setuid() error" );
return 1;
  }
  printf( "Starting ${APPLICATION}\n" );
  execl( "/bin/sh", "sh", "/path/startupscript", 0 );
  return
  
 
 
 ... 
 
 
 
 
 0;
  
 
 
 ... 
 
 
 
 

}
  
 
 
 Run the following as root (replacing tmp with whatever you want the startup script to be and replacing X with whatever group you want to be able to start and stop tomcat: 
 
 
 
 Code Block 
 
 
 
 
 
gcc tmp.c -o tmp
chown root:X tmp
chmod ugo-rwx tmp
chmod u+rwxs,g+rx tmp
  
 
 
 Now members of the tomcat group should be able to start and stop tomcat. One caveat though, you need to ensure that that your tomcat startup script is not writable by anyone other than root, otherwise your users will be able to insert commands into the script and have them run as root (very big security hole). ...  An other way is to use Iptables to redirect Port 80 and 443 to user ports (>1024)  
 
 
 
 Code Block 
 
 
 
 
 
/sbin/iptables -A FORWARD -p tcp --destination-port 443 -j ACCEPT
  
 
 
 ... 
 
 
 
 

/sbin/iptables -t nat -A PREROUTING -j REDIRECT -p tcp --destination-port 443 --to-ports 8443
  
 
 
 ... 
 
 
 
 

/sbin/iptables -A FORWARD -p tcp --destination-port 80 -j ACCEPT
  
 
 
 ... 
 
 
 
 

/sbin/iptables -t nat -A PREROUTING -j REDIRECT -p tcp --destination-port 80 --to-ports 8080
  
 
 
 ... 
 
 
 
 

/sbin/iptables-save or /etc/init.d/iptables save
  
 
 
 If you'd like "localhost:443" to also redirect to "localhost:8443", you'll need this command as well: 
 
 
 
 Code Block 
 
 
 
 
 
/sbin/iptables -t nat -A OUTPUT -p tcp -o lo -destination-port 443 -j REDIRECT --to-ports 8443
  
 
 
 Also note that if you have existing rules defined in your chains, you will need to make sure that the rules above are not ruled-out by another rule when using -A to add the above rules. For example, if you have an existing FORWARD rule that says "-j REJECT" than adding the FORWARD rule after it will have no effect. ... BSD-based Unix systems such as Mac OS X use a tool similar to iptables, called ipfw (for Internet Protocol Fire Wall). This tool is similar in that it watches all network packets go by, and can apply rules to affect those packets, such as "port-forwarding" from port 80 to some other port such as Tomcat's default 8080. The syntax of the rules is different than iptables, but the same idea. For more info, google and read the man page. Here is one possible rule to do the port-forwarding: 
 
 
 
 No Formatcode 
 
 
 
 
 

sudo ipfw add 100 fwd 127.0.0.1,8080 tcp from any to any 80 in

  
 
 
... Yet another way is to use authbind package (part of Debian- and CentOS based distributions) which allows a program that would normally require superuser privileges to access privileged network services to run as a non-privileged user. The article at http://java-notes.com/index.php/installing-tomcat-with-http-port-80-on-linux discusses how to install and configure the authbind package with Tomcat 6.0 on Linux.  How to create native launchers for Tomcat ... Honestly, the first question is "why are you rotating catalina.out"? Tomcat logs very little to catalina.out so the usual culprit is web applications that stupidly send output to System.out or System.err. If that's the case, what you ought to do is set swallowOutput="true" on the application's  configuration. That will send the output to a file configured (default) by conf/logging.properties. Once you've done that, get the application fixed to use a real logger, or at least use ServletContext.log(). If you've decided that you still absolutely positively need to rotate catalina.out, there is something that you have to understand: catalina.out is created by your shell's output redirection, just like when you type "ls -l > dir_listing.txt". So rotating the file needs to be done carefully. ... For other parameters, look at the following pages: 
 
 FAQ/Memory  
 OutOfMemory  
 If you are running Tomcat as a Windows service, then environment var

[CONF] Apache Tomcat > HowTo

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
HowTo 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 10:46 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Replace recipe for installing Tomcat as a service.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
 ... How do I set up another tomcat service on Windows, sharing the same Tomcat Home ?  This script sets up a a tomcat base directory and calls tomcat5.exe to create a windows service which will use the tomcat home given for the binaries and tomcat base you create See TomcatCreateWindowsService  ...  To install another Tomcat service using separate Home (binaries) and Base (configuration) paths you can use the service.bat script provided by Apache Tomcat. If your installation of Apache Tomcat does not have a service.bat script (in the bin directory), you can get one from a zip distributive for that version.   To install the service:  
 
 Set environment variables CATALINA_HOME, CATALINA_BASE and JAVA_HOME (or JRE_HOME) as usual, as documented in RUNNING.txt file.  
 Call the service.bat script to install the service, as shown in the Windows Service How-To in Tomcat documentation.  service.bat install NewServiceName --rename  
  How do I install Tomcat as a service under Unix? ... Honestly, the first question is "why are you rotating catalina.out"? Tomcat logs very little to catalina.out so the usual culprit is web applications that stupidly send output to System.out or System.err. If that's the case, what you ought to do is set swallowOutput="true" on the application's  configuration. That will send the output to a file configured (default) by conf/logging.properties. Once you've done that, get the application fixed to use a real logger, or at least use ServletContext.log(). If you've decided that you still absolutely positively need to rotate catalina.out, there is something that you have to understand: catalina.out is created by your shell's output redirection, just like when you type "ls -l > dir_listing.txt". So rotating the file needs to be done carefully. ... For other parameters, look at the following pages: 
 
 FAQ/Memory  
 OutOfMemory  
 If you are running Tomcat as a Windows service, then environment variables and setenv.bat script have no effect. The relevant settings for the service wrapper application are stored in the Windows registry. They can be edited via Configuration application (tomcatw.exe). See "Java" tab in the configuration dialog. The{{-Xms}} and -Xmx options are configured in fields named "Initial memory pool" and "Maximum memory pool". Other options can be added to "Java Options" field as if they were specified on the command line of java executable. ...  Warning: The above recipe on how to obtain a Context for a web application is a bit obsolete and does not work in Tomcat 7 and later (as Server is no longer a singleton). There are other ways to achieve that. An easy one is to add a Valve or Listener to a context, as those classes have access to Tomcat internals. There may be other ways mentioned in the archives of the users mailing list. How do I redirect System.out and System.err to my web page? ... This is simply telling, that the items "jms/MyQCF", and "jms/MyQ" exist, and are instances of QueueConnectionFactory, and Queue, respectively. The actual configuration is in context.xml: ... Basically, you just have to enter your values for  (the WebSphere MQ servers host name),  (the channel name),  (the queue manager name), and  (the queue name). Both these values, the associated names (HOST, PORT, CHAN, ...), and their collection is truly MQ specific. For example, with ActiveMQ, you typically have a broker URL, and a broker name, rather than HOST, PORT, CHAN, ... The main thing to know (and the reason why I am writing this, because it took me some hours to find out): How do I know the property names, their meaning, and possible values? Well, there is an excellent manual, called "WebSphere MQ Using Java". It should be easy to find by entering the title into Google. The manual contains a section, called "Administering JMS objects", which describes the objects being configured in JNDI. But the most important part is the subsection on "Properties", which contains all the required details. How do I use DataSources with Tomcat? See UsingDataSources  ... See TomcatHibernate  How do I use DataSourceRealms for authentication and authorization? ... 
 
Use your IDE to connect to Tomcat through port 1044 
 See also: FAQ/Developing  How do I debug a Tomcat application when Tomcat is run as a Windows service ? ... For IntelliJ IDEA you choose a remote debug target and set transport to "socket" and

[CONF] Apache Tomcat > HowTo

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
HowTo 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 09:01 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink and update some text.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  Permalink to this page: https://cwiki.apache.org/confluence/x/gSslBg   
 
 
 
 Table of Contents 
 
 
  ... Meta How do I add a question to this page? ... However, do not add questions without answers to this page. If you have a question about how to do something in Tomcat which has not been addressed yet, ask the tomcat-user list. Once you've figured out how to fix your problem, come back and update the Wiki to allow the rest of us to benefit from what you've learned! ... Download the source bundle or grab the source XML file files from Subversion repository. If you are not familiar with Subversion, see http://www.apache.org/dev/contributors.html.Tomcat Git repository (at GitHub).  The docs are in the webapps/docs subdirectory. They are in XML format and get processed into the HTML documentation as part of the Tomcat release. ... If you're interested in previewing your changes, you will need to follow the directions for building Tomcat yourself. The docs will be generated in the output/build/webapps/docs directory just like with any normal Tomcat distributions.  Open a Bugzilla enhancement item with the explanation of your enhancements, and attach a svn git diff or diff -u format of your patch, or create a Pull Request at GitHub. We will evaluate and commit your patch as needed. Note, that the Tomcat web site is updated with every release, so that documentation changes will not be visible until next Tomcat release. It is possible to view documentation for unreleased versions of Tomcat 7, Tomcat 8.5 and Tomcat 6, 9 that is published by ASF Buildbot. See links on the buildbot page on Apache Tomcat web site. ... 
 
  It also makes a lot of sense to use the JavaServiceWrapper.  
 How to run Tomcat without root privileges? ... #include  #include  
 
 
 
 Wiki Markup 
 
 
 
 
 
int main( int argc, char \*argv\[\] ) \{
  
 
 
 
 
if ( setuid( 0 ) != 0 ) perror( "setuid() error" ); printf( "Starting ${APPLICATION}\n" ); execl( "/bin/sh", "sh", "/path/startupscript", 0 ); return 1;  
 } Run the following as root (replacing tmp with whatever you want the startup script to be and replacing X with whatever group you want to be able to start and stop tomcat: ... 
 
/sbin/iptables -A FORWARD -p tcp --destination-port 443 -j ACCEPT  
/sbin/iptables -t nat -A PREROUTING -j REDIRECT -p tcp --destination-port 443 --to-ports 8443  
/sbin/iptables -A FORWARD -p tcp --destination-port 80 -j ACCEPT  
/sbin/iptables -t nat -A PREROUTING -j REDIRECT -p tcp --destination-port 80 --to-ports 8080  
 /sbin/iptables-save or /etc/init.d/iptables save ... 
 
/sbin/iptables -t nat -A OUTPUT -p tcp -o lo -destination-port 443 -j REDIRECT --to-ports 8443  
 Also note that if you have existing rules defined in your chains, you will need to make sure that the rules above are not ruled-out by another rule when using -A to add the above rules. For example, if you have an existing FORWARD rule that says "-j REJECT" than adding the FORWARD rule after it will have no effect. ... Honestly, the first question is "why are you rotating catalina.out"? Tomcat logs very little to catalina.out so the usual culprit is web applications that stupidly send output to System.out or System.err. If that's the case, what you ought to do is set swallowOutput="true" on the application's  configuration. That will send the output to a file configured (default) by conf/logging.properties. Once you've done that, get the application fixed to use a real logger, or at least use ServletContext.log(). If you've decided that you still absolutely positively need to rotate catalina.out, there is something that you have to understand: catalina.out is created by your shell's output redirection, just like when you type "ls -l > dir_listing.txt". So rotating the file needs to be done carefully. ... Rotate catalina.out using logrotate (or similar) 
 
 
 
 Wiki Markup 
 
 
 
 
 
To use a tool like [logrotate|http://linuxcommand.org/man_pages/logrotate8.html], you'll want to use the "copytruncate" configuration option. This will copy catalina.out to another file (like catalina.out.\[datestamp\]) and then truncates catalina.out to zero-bytes. There is a major downside to this if catalina.out is seeing a lot of action: s

[CONF] Apache Tomcat > FDA Validation

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
FDA Validation 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 08:44 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Adjust wording about testing with TCKs. The text there still remains a bit outdated.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
 ... Yes. Tomcat itself is validated to the extent it can be. Tomcat implements two several Java  Specifications: EE Specifications, most important of them are the Servlet Specification and the Java Server Pages (JSP) Specification. Each of these specifications has a Technology Compatbility Compatibility Kit (TCK), which is a collection of tests to certify a given product meets the Specification fully and accurately. The Apache Software Foundation is licensed to run these TCKs. They are run against every single major Tomcat release. No Tomcat release is pronounced stable unless it has passed both of these TCKs with 100% compliance. Therefore, every stable Tomcat release is validated to the extent of Tomcat's core functionality. ...  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Go to page history 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
View page 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Stop watching space
• 
 
 
 
 
 
 
Manage notifications 
 
 
 
 
 
 
 
 
 
 
  
 
 
This message was sent by Atlassian Confluence 6.15.8  
 
 
  
 
 
 
 
 
 
 
 
 




[CONF] Apache Tomcat > FDA Validation

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
FDA Validation 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 08:17 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink. Fix formatting. Convert links to https.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  FDA (21 CFR Part 11) Validation   Permalink to this page: https://cwiki.apache.org/confluence/x/BSolBg   Preface  This page discusses using Tomcat in an FDA validated environment, i.e. one where 21 CFR Part 11 regulations apply. Please note that although this page mentions specific companies, we do not explicitly endorse or sell anyone's services. Tomcat and Apache are not-for-profit organizations. This page is also far from a complete listing of vendors and support options. It is meant as a demonstration showing that these options do exist and that running Tomcat in a validated environment is both feasible and reasonable.  Questions  
 
 Can Tomcat be used in a validated environment?  
 Has anyone actually done it?  
 Is Tomcat itself validated?  
 What kind of support is there around validating Tomcat?fully and accurately  
 How do I know I have a validated release? How do I know no one has tampered with the release package?  
 What about security? I'm concerned about attacks.  
  Answers   
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q1 
 
 
 
Q1 
 
 
  
 
 
 Can Tomcat be used in a validated environment?  Yes. There's nothing in Tomcat's design or implementation that prevent it from being used in a validated environment. The same validation procedures and guidelines that apply to most software packages apply to Tomcat as well. Being an open-source application does not preclude Tomcat validation. In fact, it helps in at least one key aspect: the source code itself can be audited, as can the commit and change logs for the software.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q2 
 
 
 
Q2 
 
 
  
 
 
 Has anyone actually done it?  Yes. As shown in this user mailing list archive, Merck and other large companies are using Tomcat in a validated environment. In addition, there is at least one application provider (Interchange Digital) whose application runs on Tomcat that has deployed said package in numerous pharma data centers.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q3 
 
 
 
Q3 
 
 
  
 
 
 Is Tomcat itself validated?  Yes. Tomcat itself is validated to the extent it can be. Tomcat implements two Java Specifications: the Servlet Specification and the Java Server Pages (JSP) Specification. Each of these specifications has a Technology Compatbility Kit (TCK), which is a collection of tests to certify a given product meets the Specification fully and accurately. The Apache Software Foundation is licensed to run these TCKs. They are run against every single Tomcat release. No Tomcat release is pronounced stable unless it has passed both of these TCKs with 100% compliance. Therefore, every stable Tomcat release is validated to the extent of Tomcat's core functionality. ... However, we cannot validate your application's use of Tomcat. You're on your own there.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q4 
 
 
 
Q4 
 
 
  
 
 
 What kind of support is there around validating Tomcat?  Several kinds. They include: 
 
There are numerous smaller vendors and several large ones, including IBM, HP, Sun, and Novell, who offer Tomcat consulting and support services, including application auditing, environment assessments, and risk analysis. 
There are numerous vendors in addition to the above consultants, like SpringSource (formerly Covalent) and JBoss, who offer 24/7/365 enterprise-level support for Tomcat. 
The Tomcat mailing lists are extremely active and contain members of many of the above organizations, including contractors available for hire. 
  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q5 
 
 
 
Q5 
 
 
  
 
 
 How do I know I have a validated release? How do I know no one has tampered with the release package?  All Tomcat releases are signed using the Release Manager's PGP key. The key is also available in the KEYS file that ships with every Tomcat release. The same KEYS file is also available in the Tomcat SVN Git repository (here). The PGP signatures are available on all the Tomcat download pages, and can (and should!) be used to verify the release really is the signed distribution. As for tampering: every Tomcat release is also digested using the MD5 SHA-512 algorithm as specified in RFC1321 RFC6234. The MD5 SHA-512 digest is included in all the download pages. Users run MD5 run sha512sum on their local machine to verify that the digest of what they downloaded is the same as that published in the Apache download pages. That way, users a

[CONF] Apache Tomcat > Deployment

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Deployment 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 07:27 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink. Fix formatting. Convert links to https.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  Permalink to this page: https://cwiki.apache.org/confluence/x/5SklBg  Preface This section of the FAQ discusses common questions related to web application deployment. ... 
 
 Why does tomcat 5 create context configuration files?  
 Why does the memory usage increase when I redeploy a web application?  
 Answers  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q1 
 
 
 
Q1 
 
 
  
 
 
 Why does tomcat 5 create context configuration files?   Tomcat 5, Tomcat 6:   Unlike tomcat 4.x, tomcat 5.x creates context configuration files for you in its conf/[Engine name]/[Host name] directory. This is part of the change in tomcat's configuration mechanism from version 4.x to make overall configuration more robust, flexible, and enterprise-friendly. Note, however, that this has changed the recommended deployment practices for web applications. These context configuration files are created by tomcat, but not removed by tomcat, because the user may have changed them or other files in the conf directory. The suggested practice for tomcat 5 is to place context configuration files as META-INF/context.xml in your webapp, and use Tomcat's Manager webapp to deploy/undeploy your applications. More details can be found here: MARC Archive   Tomcat 7 and later:  In Tomcat 7 the default behaviour has been changed to do not auto-create those context configuration files.  The recommended practice of using META-INF/context.xml files is still the same. Those files are discovered and processed in the same way. The difference is that they are not copied to the conf/[Engine name]/[Host name]directory.  This is convenient, as you do not need to care of those copied files when undeploying your application, and you do not need to care whether the conf directory is writeable. This change in behaviour is documented in the Migration Guide.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q2 
 
 
 
Q2 
 
 
  
 
 
 Why does the memory usage increase when I redeploy a web application?  That is because your web application has a memory leak. ...  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Go to page history 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
View page 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Stop watching space
• 
 
 
 
 
 
 
Manage notifications 
 
 
 
 
 
 
 
 
 
 
  
 
 
This message was sent by Atlassian Confluence 6.15.8  
 
 
  
 
 
 
 
 
 
 
 
 




[CONF] Apache Tomcat > Database

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Database 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 07:22 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink. Fix formatting. Convert links to https.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  Permalink to this page: https://cwiki.apache.org/confluence/x/3CklBg  Preface This page is to discuss database error and DBCP. Until more content can appear here, here are some links to the mail archives to perform some searches: 
 
 database  
 datasource  
 oracle  
 mysql  
 dbpool  
 Other Links of interest: 
 
 JNDI Datasource HOW-TO  
 Questions 
 
 Is it safe to use JDBC-ODBC bridge in production environment?  
 How to use Orache thin driver?  
 How to use JDBC 3 driver with Tomcat 8?  
 Answers  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q1 
 
 
 
Q1 
 
 
  
 
 
 Is it safe to use JDBC-ODBC bridge in production environment?  No, do not use JDBC-ODBC bridge bundled with Sun's JDK with Tomcat. It was never meant for a production server environment. If you ask a question about it, everyone will tell you to not use it. If you do need to use ODBC, there are 3rd party drivers which do a pretty good job at being thread safe.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q2 
 
 
 
Q2 
 
 
  
 
 
 How to use Orache thin driver?  If you use the oracle Oracle thin driver, be sure to rename it to a jar file from a zip file. Tomcat only auto-magically loads files ending in .jar placed in a lib directory. It ignores all other file extensions.  
 
 
 
 Anchor 
 
 
 
 
 
 
 
 
 
Q3 
 
 
 
Q3 
 
 
  
 
 
 How to use JDBC 3 driver with Tomcat 8 / DBCP 2?  One of the connection pool implementations in Tomcat 8 is DBCP 2, and DBCP 2 calls Connection.isValid(int) method when no validationQuery is specified. IsValid(int) method is introduced with JDBC 4. If you must use JDBC 3 driver with Tomcat 8 / DBCP 2, make sure that you specify validationQuery attribute in pool configuration. ...  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Go to page history 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
View page 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Stop watching space
• 
 
 
 
 
 
 
Manage notifications 
 
 
 
 
 
 
 
 
 
 
  
 
 
This message was sent by Atlassian Confluence 6.15.8  
 
 
  
 
 
 
 
 
 
 
 
 




[CONF] Apache Tomcat > UsingDataSources

2019-11-24 Thread Konstantin Kolinko (Confluence)
Title: Message Title



 
 
 
There's 1 new edit on this page 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
UsingDataSources 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited this page 
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Here's the version comment 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
Konstantin Kolinko edited at 07:16 PM 
 
 
  
 
 

 
 
 
 
 
 
 
 
 Add a permalink. Fix formatting. Convert links to https.  
 
 
  
 
 
  
 
 

 
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Here's what changed: 
 
 
 
 
 
 
 
 
 
 
  Permalink to this page: https://cwiki.apache.org/confluence/x/SzElBg   How do I use DataSources with Tomcat?  When developing J2EE JavaEE web applications, the task of database connection management can be daunting. Best practice involves using a J2EE JavaEE DataSource to provide connection pooling, but configuring DataSources in web application servers and connecting your application to them is often a cumbersome process and poorly documented. ... With Tomcat the process is vastly simplified. Tomcat allows you to configure DataSources for your J2EE JavaEE web application in a context.xml file that is stored in your web application project. You don't have to mess with configuring the DataSource separately in the Tomcat server.xml, or referencing it in your application's web.xml file. Here's how: ... Install the .jar file(s) containing the JDBC driver in Tomcat's $CATALINA_BASE/lib folder. You do not need to put them in your application's WEB-INF/lib folder. When working with J2EE JavaEE DataSources, the web application server manages connections for your application. ... In the root of your web app directory structure, create a folder named META-INF (all caps). Inside that folder, create a file named context.xml that contains a Resource like this: 
 
 
 
 No Format 
 
 
 
 
 





  




  
 
 
 This example shows how to configure a DataSource for a SQL Server database named mytest located on the development machine. Simply edit the Resource name, driverClassName, username, password, and url to provide values appropriate for your JDBC driver.  Access the DataSource in Your Application  From a Servlet Here's how you might access the data in a servlet: 
 
 
 
 No Format 
 
 
 
 
   
 InitialContext ic = new InitialContext();
  DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/WallyDB");
  Connection c = ds.getConnection();
  ...
  c.close();
  
 
 
 ... Known-Working examples for other Databases 
 
 
 
 No Format 
 
 
 
 
 
 
  
 
 

 
 
 
 No Format 
 
 
 
 
 
 
  
 
 
 ... This technique is Tomcat-specific. If you deploy your web application to another application server, you will need to configure the database according to your application server's documentation, and reference it in your application's web.xml.  CategoryFAQ   
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Go to page history 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
View page 
 
 
  
 
 
  
 
 
  
 
 
  
 
 
 
 
 
 
 
 
 
 
Stop watching space
• 
 
 
 
 
 
 
Manage notifications 
 
 
 
 
 
 
 
 
 
 
  
 
 
This message was sent by Atlassian Confluence 6.15.8