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
This article is about common issues of Tomcat and how to solve them.
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.
For those config file. the standard deployment descriptor web.xml
for example, If they can’t be parsed properly by tomcat they are so called bad config files.
Here are common reasons
When deploying with a .war
file rather than a unpacked folder, if it goes well Tomcat will generate an unpacked version of the .war
file.
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.
If your .war
file 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.
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-plugin
is a proper solution.