About this ebook
Apache Tomcat (or simply Tomcat) is an open source servlet container developed by the Apache Software Foundation (ASF). The latest major stable release, Apache Tomcat version 7 implements the Servlet 3 and JavaServer Pages 2 specifications from the Java Community Process, and includes many additional features that make it a useful platform for developing and deploying web applications and web services.
Apache Tomcat 7 Essentials follows a practical approach to teach installing, configuring, and maintaining Tomcat. It helps you to understand the middle architecture for hosting multiple websites and also provides the confidence to implement middleware support. It imparts to you the capacity to resolve migration issues and also provides regular maintenance solutions. This is the first and only book to cover upgrading to Tomcat 7 from previous versions.
The journey of the reader starts at the beginner level and ends at the expert level. The content is designed in such a way that it balances the theory and practical approach for understanding concepts related to handling middle ware and web issues.
In this book, you will go through a three-phase life cycle. The first cycle consists of installation, configuration of Tomcat 7 on different OS, and other configurations related to JDBC, port, deployment etc.
The second phase deals with the building of enterprise application setup and high availability architecture (clustering load balancing). The third and critical phase will teach you to handle critical issues, performance tuning, and best practices for various environment stacks like dev/QA/stage/production.
This book gives you a wider vision of using Tomcat 7 in web technologies and the skill to optimize their performance using Apache Tomcat 7.
ApproachThis book is a step-by-step tutorial for anyone wanting to learn Apache Tomcat 7 from scratch. There are plenty of illustrations and examples to escalate you from a novice to an expert with minimal strain.
Who this book is forIf you are a J2EE administrator, migration administrator, technical architect, or a project manager for a web hosting domain, and are interested in Apache Tomcat 7, then this book is for you. If you are someone responsible for installation, configuration, and management of Tomcat 7, then too, this book will be of help to you.
Tanuj Khare
Tanuj Khare has worked as a professional in IT for six+ years. He is involved in Process improvements using ITIL framework and techniques (LEAN and Six sigma). He is MCSA and ITIL certified and has expertise in handling critical production server issues and has a track record of dealing with many complex problems. His quick resolution to issues faced in a production environment helped his team and clients a lot. Tanuj has SME (subject matter expertise) in Tomcat, weblogic, and JBOSS Server Administration. His experience includes working with large enterprise web hosting environment for J2EE container and small teams and his quick turnaround time resulted in on-time delivery. Apart from this, his technical expertise in root cause analysis, problem management, migration of enterprise application, and upgrade of web application servers is commendable. Until now he has done around 100+ enterprise application migrations. He has also done J2EE web and application upgrades and managed environments with 1,000+ middleware instances. Outside of work life, Tanuj enjoys playing table tennis and exploring new technologies. Tanuj is a good dancer. This is his first book.
Related to Apache Tomcat 7 Essentials
Related ebooks
PostgreSQL Server Programming - Second Edition Rating: 0 out of 5 stars0 ratingsWebSphere Application Server 7.0 Administration Guide Rating: 0 out of 5 stars0 ratingsBuilding Web Services with Microsoft Azure Rating: 0 out of 5 stars0 ratingsNginx Troubleshooting Rating: 0 out of 5 stars0 ratingsMastering Go Network Automation Rating: 0 out of 5 stars0 ratingsMastering MariaDB Rating: 0 out of 5 stars0 ratingsNginx HTTP Server - Third Edition Rating: 0 out of 5 stars0 ratingsHyper-V 2016 Best Practices Rating: 0 out of 5 stars0 ratingsLinux Shell Scripting Cookbook, Second Edition Rating: 0 out of 5 stars0 ratingsGetting Started with PowerShell Rating: 0 out of 5 stars0 ratingsLearn Docker - .NET Core, Java, Node.JS, PHP or Python: Learn Collection Rating: 5 out of 5 stars5/5Linux Networking Cookbook Rating: 0 out of 5 stars0 ratingsRed Hat OpenShift A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratingsImplementing OpenShift Rating: 0 out of 5 stars0 ratingsMastering Apache Maven 3 Rating: 0 out of 5 stars0 ratingsCentOS System Administration Essentials Rating: 0 out of 5 stars0 ratingsMastering Linux Shell Scripting Rating: 4 out of 5 stars4/5SSL/TLS Under Lock and Key: A Guide to Understanding SSL/TLS Cryptography Rating: 4 out of 5 stars4/5Work with the Command-line: To Manage Files and Directories in Ubuntu Rating: 5 out of 5 stars5/5Learn Batch File Programming! Rating: 1 out of 5 stars1/5Active Directory: Network Management Best Practices For System Administrators Rating: 0 out of 5 stars0 ratingsWindows Server Administration Fundamentals Rating: 0 out of 5 stars0 ratingsInstant Windows PowerShell Guide Rating: 0 out of 5 stars0 ratingsThe Concise Guide to SSL/TLS for DevOps Rating: 5 out of 5 stars5/5Ansible DevOps Cookbook Rating: 0 out of 5 stars0 ratingsHigh Availability MySQL Cookbook Rating: 0 out of 5 stars0 ratingsWindows Failover Clustering Design Handbook Rating: 0 out of 5 stars0 ratingsMastering Bash Rating: 5 out of 5 stars5/5Learn JSP in 24 Hours Rating: 0 out of 5 stars0 ratingsInstant Citrix XenApp Rating: 5 out of 5 stars5/5
Computers For You
Slenderman: Online Obsession, Mental Illness, and the Violent Crime of Two Midwestern Girls Rating: 4 out of 5 stars4/5The Professional Voiceover Handbook: Voiceover training, #1 Rating: 5 out of 5 stars5/5The Invisible Rainbow: A History of Electricity and Life Rating: 5 out of 5 stars5/5Elon Musk Rating: 4 out of 5 stars4/5Standard Deviations: Flawed Assumptions, Tortured Data, and Other Ways to Lie with Statistics Rating: 4 out of 5 stars4/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution Rating: 4 out of 5 stars4/5Learning the Chess Openings Rating: 5 out of 5 stars5/5Excel 101: A Beginner's & Intermediate's Guide for Mastering the Quintessence of Microsoft Excel (2010-2019 & 365) in no time! Rating: 0 out of 5 stars0 ratingsMastering ChatGPT: 21 Prompts Templates for Effortless Writing Rating: 4 out of 5 stars4/5Data Analytics for Beginners: Introduction to Data Analytics Rating: 4 out of 5 stars4/5CompTIA Security+ Get Certified Get Ahead: SY0-701 Study Guide Rating: 5 out of 5 stars5/5Deep Search: How to Explore the Internet More Effectively Rating: 5 out of 5 stars5/5Uncanny Valley: A Memoir Rating: 4 out of 5 stars4/5Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are Rating: 4 out of 5 stars4/5The ChatGPT Millionaire Handbook: Make Money Online With the Power of AI Technology Rating: 4 out of 5 stars4/5Alan Turing: The Enigma: The Book That Inspired the Film The Imitation Game - Updated Edition Rating: 4 out of 5 stars4/5Procreate for Beginners: Introduction to Procreate for Drawing and Illustrating on the iPad Rating: 5 out of 5 stars5/5The Hacker Crackdown: Law and Disorder on the Electronic Frontier Rating: 4 out of 5 stars4/5Some Future Day: How AI Is Going to Change Everything Rating: 0 out of 5 stars0 ratingsThe Self-Taught Computer Scientist: The Beginner's Guide to Data Structures & Algorithms Rating: 0 out of 5 stars0 ratingsGrokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5An Ultimate Guide to Kali Linux for Beginners Rating: 3 out of 5 stars3/5The Insider's Guide to Technical Writing Rating: 0 out of 5 stars0 ratingsHow to Create Cpn Numbers the Right way: A Step by Step Guide to Creating cpn Numbers Legally Rating: 4 out of 5 stars4/5People Skills for Analytical Thinkers Rating: 5 out of 5 stars5/5
Reviews for Apache Tomcat 7 Essentials
0 ratings0 reviews
Book preview
Apache Tomcat 7 Essentials - Tanuj Khare
Table of Contents
Apache Tomcat 7 Essentials
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Installation of Tomcat 7
History of Tomcat
Tomcat support matrix
Features and enhancements of Apache Tomcat 7
Web application memory leak detection and prevention
Servlet 3.0
Improved logging
Aliases
Installation of Tomcat 7
How to download the Tomcat software
Binary package
RPM/exe
Source
Prerequisites for the Tomcat 7 installation
Installation of Java
Installation of Java in Linux
Installation of Java in Windows
Configuration of OS environment variables
What is JAVA_HOME?
Setting the JAVA_HOME and PATH variable in Windows
Setting the global path variable in Windows
Setting the JAVA_HOME and the PATH environment variable in Linux
Installation of Apache Tomcat 7
Installation on a Windows environment
Installation on a Linux environment
Startup and shutdown of Tomcat services
Services in Windows
Services in Linux
Startup script
Shutdown script
Verification of Tomcat status
Common problems and troubleshooting in installation
Error: Permission denied for the Java binary
Error: Tomcat is not able to find JAVA_HOME
Error: Error in the logs showing port already in use
Summary
2. Configuration and Deployment
Configuration files and their usage
Configuration of Tomcat 7
DataSource configuration
JDBC
JNDI
DataSource
DataSource for Oracle
DataSource for MySQL
DataSource for PostgreSQL
Comparison of the datasource for common databases
Tomcat Manager configuration
Enabling the Tomcat Manager
Context path
Enabling the context path
GUI using the Tomcat Web Application Manager
Command-line configuration in server.xml
Deployment in Tomcat 7
Structure of the WebArchive
Archive Files
Exploded archive directories
Deployment operations
Types of deployment
Ways of application deployment in Tomcat 7
Common issues in deployment, configuration, and their troubleshooting
Summary
3. Performance Tuning
Performance tuning for Tomcat 7
Why we need performance tuning?
How to start performance tuning
Tomcat components tuning
Types of connectors for Tomcat 7
Java HTTP Connector
Java AJP Connector
APR (AJP/HTTP) Connector
Thread optimization for Tomcat 7
Shared thread pool (shared executor)
Dedicated thread pool
Shared thread pool versus dedicated thread pool
maxThreads
maxKeepAlive
JVM tuning
Why do we need to tune the JDK for Tomcat?
JMAP (Memory Map)
Syntax for jmap
How to increase the heap size in Tomcat 7
Garbage collection
How garbage collection works
JVM options
Standard options
Non-standard options
Parameters displayed in the logs for GC
SurvivorRatio
OS tuning
Summary
4. Integration of Tomcat with the Apache Web Server
User request flow (web/application level)
Why the Apache HTTP server
Installation of the Apache HTTP
Apache HTTP installation on Windows
How to monitor the Apache service
Installation of Apache HTTP on Linux (non-DOS environment)
Apache Portable Runtime
Installation of APR/APR-util
Apache Jserv protocol
Installation and configuration of mod_jk
Installation of mod_jk
Configuration of mod_jk in Apache
mod_proxy configuration
Comparison between mod_jk and mod_proxy
IIS integration with Tomcat 7
Prerequisites
Steps for installation
Common issues and troubleshooting for integration
Summary
5. Securing Tomcat 7
Tomcat Manager
Tomcat security permissions
catalina.properties
catalina.policy
System Code permissions
Catalina Code permissions (Tomcat core permission)
Web application permissions
tomcat-users.xml
server.xml
Enabling Tomcat Manager
How to enable the Tomcat Manager
Securing Tomcat 7 for production
Tomcat settings
Connector Port
Slimming of Tomcat application
Disable hot deployment
Non-Tomcat settings
Service as a separate user
Firewall
Password
SSL configuration on Tomcat 7
Types of SSL certificates
Process of installing SSL
Summary
6. Logging in Tomcat 7
JULI
Loggers, appenders, and layouts
Types of logging in Tomcat 7
Application log
Server log
Console log
Access log
Host manager
Types of log levels in Tomcat 7
Log4j
Log level for log4j
How to use log4j
Log level mapping
Values for Tomcat 7
Log analysis
Helpful commands for log analysis
Summary
7. Troubleshooting in Tomcat
Common problem areas for web administrators
How to troubleshoot a problem
Slowness issue in applications
How to solve slowness issues in Tomcat 7
User end troubleshooting
Web server troubleshooting
Tomcat 7 troubleshooting
Troubleshooting at the database level
Telnet DB server IP port
JVM analysis in the Tomcat instance
How to obtain a thread dump in Tomcat 7
Thread dump using Kill command
Thread dump using jstack
How to analyze the thread dump for Tomcat instance
Thread dump analysis using Samurai
Thread dump analysis using the Thread Dump Analyzer
Errors and their solutions
JVM (memory) issues
Out of Memory exception
OutOfMemoryError: PermGen space
Stack over flow exception
Database-related issues
Broken pipe exception
Timeout waiting for an idle object
Database connectivity exception
Web server benchmarking
ApacheBench
JMeter
Summary
8. Monitoring and Management of Tomcat 7
Different ways of monitoring
Monitoring setup for a web application and database server
Tomcat Manager in Tomcat 7
Monitoring in Tomcat 7
Summary of the Server Status of Tomcat 7
Complete Server Status of Tomcat 7
Application List
JVM
Connections on the HTTP port (8080)
Connections on the AJP
JConsole configuration on Tomcat 7
Remote JMX enabling
How to connect to the JConsole
Different tabs for the JConsole and their features
Memory overview
Threads overview
VM Summary and Overview
MBeans
Types of MBeans
Summary
9. Clustering in Tomcat 7
What is a cluster?
Benefits of clustering
Disadvantages of clustering
Clustering architecture
Vertical clustering
Advantages of vertical clustering
Disadvantages of vertical clustering
Horizontal clustering
Advantages of horizontal clustering
Disadvantages of horizontal clustering
Vertical clustering in Apache Tomcat 7
Installation of the Tomcat instance
Configuration of a vertical cluster
Configuration of instance 1
Configuration of instance 2
Apache web server configuration for vertical clustering
Horizontal clustering in Apache Tomcat 7
Installation of the Tomcat instance
Configuration of the cluster
Configuration of instance 1
Configuration of instance 2
Apache web server configuration for horizontal clustering
Testing of the clustered instance
Monitoring of Tomcat clustering
Summary
10. Tomcat Upgrade
Different types of environment
Development environment
Quality Assurance environment
Staging environment
Production environment
Life cycle of the upgrade
Tomcat upgrade from 6 to 7
Prerequisites for Tomcat 7
Installation of Tomcat 7 for the upgrade
Configuration of Tomcat 7
JVM configuration
Database connection settings
Application migration
Alias configuration
ITIL process implementation
Availability management
Capacity management
Service Transition
Summary
11. Advanced Configuration for Apache Tomcat 7
Virtual hosting
Name-based virtual hosting
IP-based virtual hosting
Virtual hosting in Tomcat 7
Hostname aliases
Multiple applications hosting on a single Tomcat 7 instance
Multiple Tomcat environments—Development/QA/Stage/Production
Tuning cache
Optimization of Tomcat 7
Running Tomcat 7 as a non privileged user
Summary
Index
Apache Tomcat 7 Essentials
Apache Tomcat 7 Essentials
Copyright © 2012 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: March 2012
Production Reference: 1160312
Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK..
ISBN 978-1-84951-662-4
www.packtpub.com
Cover Image by Vinayak Chittar ( <[email protected]> )
Credits
Author
Tanuj Khare
Reviewers
Zeeshan Chawdhary
Ty Lim
Vidyasagar N V
Acquisition Editor
Usha Iyer
Lead Technical Editor
Susmita Panda
Technical Editor
Unnati Shah
Copy Editor
Laxmi Subramanian
Project Coordinator
Vishal Bodwani
Proofreader
Linda Morris
Indexer
Rekha Nair
Graphics
Valentina D'Silva
Manu Joseph
Production Coordinator
Alwin Roy
Cover Work
Alwin Roy
About the Author
Tanuj Khare has been a professional in IT for over six years. He is involved in process improvements using the ITIL framework and techniques such as Lean Six Sigma. He is MCSA and ITIL certified, and has expertise in handling critical production server issues. He also has a track record of dealing with many complex problems. His quick resolution to issues faced in the production environment has helped his team and clients in a big way.
Tanuj has Subject Matter Expertise (SME) in Tomcat, WebLogic, and JBoss server administration. His experience includes working with large-enterprise web hosting environments for J2EE containers with small teams, and his quick turnaround time gave on-time delivery. Apart from this, his technical expertise in Root Cause Analysis, Problem Management, Migration of enterprise applications, and upgrade of web application servers are commendable. Up to now, he has migrated more than 100 enterprise applications and upgraded J2EE web applications. He has also managed environments with over 1000 middleware instances.
Apart from work life, Tanuj enjoys playing Table Tennis and exploring new technologies. He is a good dancer. This is his first book.
Acknowledgement
I would like to express my gratitude to all the people who have helped me to make this book better. I thank Ranveer Chandel, who has helped me to provide high technical standards for this book.
I would like to thank Archana Kannoujia, who has patiently helped me to improve my writing style.
I would like to thank Mitesh Parikh and Giri Moturi for their support.
I would like to thank Usha Iyer, Vishal Bodwani, Susmita Panda, and everyone else at Packt Publishing for all their hard work to get this book published. A special thanks to Unnati Shah for her hard work and dedication to get this book published.
I would like to thank Ty Lim,Vidyasagar N V, and Zeeshan Chawdhury for providing their valuable guidance and support that helped me achieve the high technical standards.
And finally, I'd like to thank all my colleagues and friends, with whom I've worked throughout my career, for contributing to my professional development.
About the Reviewers
Zeeshan Chawdhary is the CTO of Wcities Inc., a location-based travel content provider, running technical operations from their Technical Headquarters in Mumbai.
He is a do-it-all and code-in-any-language guy, having worked with various technologies from 3D gaming to consumer websites, from iPhone apps to serving over 30 million hits over the Cloud.
He is currently writing two real-world-use books with Packt Publishing which are, iPhone Location Aware Applications by Example - Beginners Guide and Windows Phone 7.5 - Building Location Aware Applications.
He can be reached at imzeeshan on Twitter. He currently blogs at http://justgeeks.in.
I would like to thank the great people at Packt for letting me review this book. Special thanks to Vishal Bodwani, Susmita Panda, Leena Purkait, Amey Kanse, Alina Lewis, and a special mention for Mary Nadar, for having introduced me to the Packt family.
Ty Lim has been in the IT industry for over 15 years. He has worked for several startup companies in the mid 1990s and found himself working at several major corporations after his stint in Silicon Valley. He has worked in the following industries: Software Development, Consulting, Healthcare, Telecommunications, and Finance. He has experience in utilizing JBoss, Tomcat, and WebSphere middleware technologies. He holds a Bachelor of Science degree in Computer Science from the University of the Pacific, and is currently pursuing a Master of Science degree in CIS from Boston University.
He has also worked on IBM WebSphere Application Server v7.0 Security, Packt Publishing.
I would like to thank all my friends and family for their continued support. I am truly blessed to have such great support. It is because of all of you that I consider myself a very happy man.
Vidyasagar N V was interested in Computer Science since his early age. Some of his serious work in computers and computer networks began during his high school days. Later, he went to the prestigious institute of technology, Banaras Hindu University for his B.Tech. He has been working as a Software Developer, Data Expert, developing and building scalable systems since then. He has worked with a variety of 2nd, 3rd, and 4th generation languages. He has also worked with Flat files, Indexed files, Hierarchical databases, Network databases, Relational databases, NoSQL databases, Hadoop, and related technologies.
Currently, he is working as a Senior Developer at Ziva Software Pvt. Ltd, developing a big data-based structured data extraction technique from the Web and local information. He enjoys producing high-quality software, web-based solutions, and designing secure and scalable data systems.
He has also worked on PHP and MongoDB Web Development Beginner's Guide, Packt Publishing.
He can be reached at <[email protected]>.
I thank the almighty for giving me such a blessed life and thank my parents, Mr. N. Srinivasa Rao and Mrs. Latha Rao, and my family who supported and backed me throughout my life. I thank my friends and all those people who donated their time, effort, and expertise by participating in open source software projects. Also, thanks to Packt Publishing for selecting me as one of the technical reviewers for this wonderful book. It is my honor to be a part of this book.
www.PacktPub.com
Support files, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
Why Subscribe?
Fully searchable across every book published by Packt
Copy and paste, print and bookmark content
On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
I would like to dedicate this book to my mom, Mrs. Shashi Khare and dad, Mr. Rajkumar Khare, for standing beside me during the writing of this book.
Without their support and encouragement, completing this book would have been a much more difficult task.
Preface
This book will help you resolve these issues and boost your confidence in handling Apache Tomcat 7 administration using the tips, tricks, and best practices used by various industry experts to maintain their middleware infrastructure. The best thing that the author did while designing the content is a practical solution, with a detailed description of why we are doing this solution.
Apache Tomcat (or Jakarta Tomcat, or simply Tomcat) is an open source servlet container developed by The Apache Software Foundation. The latest major stable release, Apache Tomcat version 7, implements the Servlet 3 and JavaServer Pages 2 specifications from the Java Community Process. It includes many additional features that make it a useful platform for developing and deploying web applications