You are previewing Apache Tomcat 7 Essentials.
O'Reilly logo
Apache Tomcat 7 Essentials

Book Description

This book takes you from beginner to expert in logical stages, covering all the essentials of Tomcat 7 from trouble-free installation to building your own middleware servers. Packed with examples and illustrations.

  • Readymade solution for web technologies for migration/hosting and supporting environment for Tomcat 7

  • Tips, tricks, and best practices for web hosting solution providers for Tomcat 7

  • Content designed with practical approach and plenty of illustrations

  • In Detail

    Apache Tomcat (or Jakarta 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.

    Table of Contents

    1. Apache Tomcat 7 Essentials
      1. Apache Tomcat 7 Essentials
      2. Credits
      3. About the Author
      4. Acknowledgement
      5. About the Reviewers
      6. www.PacktPub.com
            1. Support files, eBooks, discount offers and more
              1. Why Subscribe?
              2. Free Access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Installation of Tomcat 7
        1. History of Tomcat
          1. Tomcat support matrix
          2. Features and enhancements of Apache Tomcat 7
            1. Web application memory leak detection and prevention
            2. Servlet 3.0
            3. Improved logging
            4. Aliases
        2. Installation of Tomcat 7
          1. How to download the Tomcat software
            1. Binary package
            2. RPM/exe
            3. Source
          2. Prerequisites for the Tomcat 7 installation
            1. Installation of Java
              1. Installation of Java in Linux
              2. Installation of Java in Windows
            2. Configuration of OS environment variables
              1. What is JAVA_HOME?
              2. Setting the JAVA_HOME and PATH variable in Windows
              3. Setting the global path variable in Windows
              4. Setting the JAVA_HOME and the PATH environment variable in Linux
          3. Installation of Apache Tomcat 7
            1. Installation on a Windows environment
            2. Installation on a Linux environment
          4. Startup and shutdown of Tomcat services
            1. Services in Windows
            2. Services in Linux
            3. Startup script
            4. Shutdown script
          5. Verification of Tomcat status
        3. Common problems and troubleshooting in installation
          1. Error: Permission denied for the Java binary
          2. Error: Tomcat is not able to find JAVA_HOME
          3. Error: Error in the logs showing port already in use
        4. Summary
      9. 2. Configuration and Deployment
        1. Configuration files and their usage
        2. Configuration of Tomcat 7
          1. DataSource configuration
            1. JDBC
            2. JNDI
            3. DataSource
              1. DataSource for Oracle
              2. DataSource for MySQL
              3. DataSource for PostgreSQL
        3. Comparison of the datasource for common databases
          1. Tomcat Manager configuration
            1. Enabling the Tomcat Manager
          2. Context path
            1. Enabling the context path
              1. GUI using the Tomcat Web Application Manager
              2. Command-line configuration in server.xml
        4. Deployment in Tomcat 7
          1. Structure of the WebArchive
            1. Archive Files
              1. Exploded archive directories
              2. Deployment operations
        5. Types of deployment
          1. Ways of application deployment in Tomcat 7
        6. Common issues in deployment, configuration, and their troubleshooting
        7. Summary
      10. 3. Performance Tuning
        1. Performance tuning for Tomcat 7
          1. Why we need performance tuning?
        2. How to start performance tuning
        3. Tomcat components tuning
          1. Types of connectors for Tomcat 7
            1. Java HTTP Connector
            2. Java AJP Connector
            3. APR (AJP/HTTP) Connector
          2. Thread optimization for Tomcat 7
            1. Shared thread pool (shared executor)
            2. Dedicated thread pool
              1. Shared thread pool versus dedicated thread pool
              2. maxThreads
              3. maxKeepAlive
        4. JVM tuning
          1. Why do we need to tune the JDK for Tomcat?
            1. JMAP (Memory Map)
              1. Syntax for jmap
          2. How to increase the heap size in Tomcat 7
            1. Garbage collection
              1. How garbage collection works
          3. JVM options
            1. Standard options
            2. Non-standard options
            3. Parameters displayed in the logs for GC
            4. SurvivorRatio
        5. OS tuning
        6. Summary
      11. 4. Integration of Tomcat with the Apache Web Server
        1. User request flow (web/application level)
        2. Why the Apache HTTP server
        3. Installation of the Apache HTTP
          1. Apache HTTP installation on Windows
            1. How to monitor the Apache service
          2. Installation of Apache HTTP on Linux (non-DOS environment)
            1. Apache Portable Runtime
              1. Installation of APR/APR-util
        4. Apache Jserv protocol
          1. Installation and configuration of mod_jk
            1. Installation of mod_jk
            2. Configuration of mod_jk in Apache
          2. mod_proxy configuration
          3. Comparison between mod_jk and mod_proxy
        5. IIS integration with Tomcat 7
          1. Prerequisites
          2. Steps for installation
        6. Common issues and troubleshooting for integration
        7. Summary
      12. 5. Securing Tomcat 7
        1. Tomcat Manager
        2. Tomcat security permissions
          1. catalina.properties
          2. catalina.policy
            1. System Code permissions
            2. Catalina Code permissions (Tomcat core permission)
            3. Web application permissions
          3. tomcat-users.xml
          4. server.xml
        3. Enabling Tomcat Manager
          1. How to enable the Tomcat Manager
        4. Securing Tomcat 7 for production
          1. Tomcat settings
            1. Connector Port
            2. Slimming of Tomcat application
            3. Disable hot deployment
          2. Non-Tomcat settings
            1. Service as a separate user
            2. Firewall
            3. Password
        5. SSL configuration on Tomcat 7
          1. Types of SSL certificates
          2. Process of installing SSL
        6. Summary
      13. 6. Logging in Tomcat 7
        1. JULI
        2. Loggers, appenders, and layouts
        3. Types of logging in Tomcat 7
          1. Application log
          2. Server log
          3. Console log
          4. Access log
          5. Host manager
        4. Types of log levels in Tomcat 7
        5. Log4j
          1. Log level for log4j
            1. How to use log4j
          2. Log level mapping
        6. Values for Tomcat 7
        7. Log analysis
          1. Helpful commands for log analysis
        8. Summary
      14. 7. Troubleshooting in Tomcat
        1. Common problem areas for web administrators
        2. How to troubleshoot a problem
          1. Slowness issue in applications
            1. How to solve slowness issues in Tomcat 7
              1. User end troubleshooting
              2. Web server troubleshooting
              3. Tomcat 7 troubleshooting
            2. Troubleshooting at the database level
              1. Telnet DB server IP port
              2. JVM analysis in the Tomcat instance
        3. How to obtain a thread dump in Tomcat 7
          1. Thread dump using Kill command
          2. Thread dump using jstack
            1. How to analyze the thread dump for Tomcat instance
          3. Thread dump analysis using Samurai
          4. Thread dump analysis using the Thread Dump Analyzer
          5. Errors and their solutions
            1. JVM (memory) issues
              1. Out of Memory exception
              2. OutOfMemoryError: PermGen space
              3. Stack over flow exception
            2. Database-related issues
              1. Broken pipe exception
              2. Timeout waiting for an idle object
              3. Database connectivity exception
        4. Web server benchmarking
            1. ApacheBench
            2. JMeter
        5. Summary
      15. 8. Monitoring and Management of Tomcat 7
        1. Different ways of monitoring
        2. Monitoring setup for a web application and database server
        3. Tomcat Manager in Tomcat 7
        4. Monitoring in Tomcat 7
          1. Summary of the Server Status of Tomcat 7
            1. Complete Server Status of Tomcat 7
              1. Application List
              2. JVM
              3. Connections on the HTTP port (8080)
              4. Connections on the AJP
        5. JConsole configuration on Tomcat 7
          1. Remote JMX enabling
          2. How to connect to the JConsole
          3. Different tabs for the JConsole and their features
            1. Memory overview
            2. Threads overview
            3. VM Summary and Overview
            4. MBeans
              1. Types of MBeans
        6. Summary
      16. 9. Clustering in Tomcat 7
        1. What is a cluster?
          1. Benefits of clustering
          2. Disadvantages of clustering
        2. Clustering architecture
          1. Vertical clustering
            1. Advantages of vertical clustering
            2. Disadvantages of vertical clustering
          2. Horizontal clustering
            1. Advantages of horizontal clustering
            2. Disadvantages of horizontal clustering
        3. Vertical clustering in Apache Tomcat 7
          1. Installation of the Tomcat instance
          2. Configuration of a vertical cluster
            1. Configuration of instance 1
            2. Configuration of instance 2
            3. Apache web server configuration for vertical clustering
        4. Horizontal clustering in Apache Tomcat 7
          1. Installation of the Tomcat instance
          2. Configuration of the cluster
            1. Configuration of instance 1
            2. Configuration of instance 2
            3. Apache web server configuration for horizontal clustering
        5. Testing of the clustered instance
        6. Monitoring of Tomcat clustering
        7. Summary
      17. 10. Tomcat Upgrade
        1. Different types of environment
          1. Development environment
          2. Quality Assurance environment
          3. Staging environment
          4. Production environment
        2. Life cycle of the upgrade
        3. Tomcat upgrade from 6 to 7
          1. Prerequisites for Tomcat 7
          2. Installation of Tomcat 7 for the upgrade
          3. Configuration of Tomcat 7
            1. JVM configuration
            2. Database connection settings
            3. Application migration
            4. Alias configuration
        4. ITIL process implementation
          1. Availability management
          2. Capacity management
          3. Service Transition
        5. Summary
      18. 11. Advanced Configuration for Apache Tomcat 7
        1. Virtual hosting
          1. Name-based virtual hosting
          2. IP-based virtual hosting
        2. Virtual hosting in Tomcat 7
        3. Hostname aliases
        4. Multiple applications hosting on a single Tomcat 7 instance
        5. Multiple Tomcat environments—Development/QA/Stage/Production
        6. Tuning cache
        7. Optimization of Tomcat 7
          1. Running Tomcat 7 as a non privileged user
        8. Summary