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

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.



  • 22
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值