Tomcat Notes: Common Issues Of Tomcat

This is a personal study notes of Apache Tomcat. Below are main reference material.

- YouTube Apache Tomcat Full Tutorial,owed by Alpha Brains Courses. https://www.youtube.com/watch?v=rElJIPRw5iM&t=801s



  • 1、Overview
  • 2、Trouble shooting
    • 2.1、Bad Config file
      • 2.1.1、What is It
      • 2.1.2、How To Troubleshooting
    • 2.2、JSP Problems
      • 2.2.1、What Is It
      • 2.2.2、Why Important


1、Overview

This article is about common issues of Tomcat and how to solve them.

2、Trouble shooting

The errors we talk about in here is that occur between the web app and the web container, Catalina.

The errors in app logic is not covered in this article.

There are 3 types of errors in broad categories and each one of them features differently, making it easier for us to narrow focus.

2.1、Bad Config file

2.1.1、What is It

For those config file. the standard deployment descriptor web.xmlfor example, If they can’t be parsed properly by tomcat they are so called bad config files.

Here are common reasons

  • The XML is syntactically ill-formed (i.e., lack of a end tag)
  • The XML doesn’t match a required schema (i.e. can’t pass a ‘validating parse’).

2.1.2、How To Troubleshooting

When deploying with a .warfile rather than a unpacked folder, if it goes well Tomcat will generate an unpacked version of the .warfile.

Thus if there is no unpacked file, the most possible case is that you have at least 1 bad config file.

It’s time to check config files one by one.



2.2、JSP Problems

2.2.1、What Is It

If your .warfile include some JSP file they will eventually be translated into servlets by Jasper so that browsers can understand.

But Java syntax errors could occur when compiling, such as the following line lacking of a semicolon.

System.out.print("Hello World")     // ';' expected

Here is the content of a JSP file with JSP problem.

<!doctype>
<html>
  <body>
    <!-- Below is a 'scriplet': Java code embedded in an HTML template.
         The code contains errors, which will prevent deployment.
       -->
    <%
        out.println("Hello World");  //### Error: missing semicolon in statement
    %>
  </body>
</html>


So errors ,coming from Java code which is included by JSP file and result in failing to compile, is called JSP problem.


2.2.2、Why Important

By default, JSP doesn’t be translated into servlets until the first client hit Tomcat, which means that we deploy an application with errors that should be discovered when compiling project.

We should turn on a switch in web.xml, translating all JSP into servlets when deploying or before deploying so that we can find potential errors as soon as possible.

And there’re many ways to precompile JSP files. For example, if your project use maven to build, then precompile JSP with maven plugin jspc-maven-pluginis a proper solution.



你可能感兴趣的:(Tomcat,tomcat,java)