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
文章来源地址https://www.toymoban.com/news/detail-799055.html
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.xml
for 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 .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.
2.2、JSP Problems
2.2.1、What Is It
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.
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-plugin
is a proper solution.文章来源:https://www.toymoban.com/news/detail-799055.html
到了这里,关于Tomcat Notes: Common Issues Of Tomcat的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!