A brief discussion on the solution of Tomcat garbled code and port occupation

A brief discussion on the solution of Tomcat garbled code and port occupation

Tomcat server is a free and open source Web application server. It is a lightweight application server and is widely used in small and medium-sized systems and in situations where there are not many concurrent users. It is the first choice for developing and debugging JSP programs. However, some friends will encounter various problems when starting Tomcat, such as garbled characters, port occupation, and flash back after starting Tomcat startup.bat. Here we will solve them one by one.

Problem 1: Garbled characters appear after Tomcat's startup.bat is started

insert image description here

Find the conf directory under the Tomcat file and modify the value of java.util.logging.ConsoleHandler.encoding in the logging.properties file to GBK

insert image description here

Restart Tomcat. If the startup page you see is like this, it means the garbled problem has been solved.

insert image description here

Problem 2: Port occupation that disappears suddenly

When you start Tomcat, it may flash and quit. In fact, you can still see the log output by the Tomcat terminal. At this time, you need to quickly take a screenshot to capture the exception, which is too difficult.

insert image description here

The most correct way is to check the logs and find the log of catalina on that day in the logs directory under the Tomcat directory . I found C:\develop\Tomcat\apache-tomcat-8.5.47\logs\catalina.2019-10-17.log here. In the log, you can see output like this: Address already in use: bind indicates that the port is occupied.

17-Oct-2019 11:14:30.521 SEVERE [main] org.apache.catalina.core.StandardService.initInternal Failed to initialize connector [Connector[HTTP/1.1-8080]]
	org.apache.catalina.LifecycleException: Protocol handler initialization failed
		at org.apache.catalina.connector.Connector.initInternal(Connector.java:995)
		at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
		at org.apache.catalina.core.StandardService.initInternal(StandardService.java:552)
		at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
		at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:848)
		at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
		at org.apache.catalina.startup.Catalina.load(Catalina.java:639)
		at org.apache.catalina.startup.Catalina.load(Catalina.java:662)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
		at java.lang.reflect.Method.invoke(Method.java:498)
		at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:309)
		at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
	Caused by: java.net.BindException: Address already in use: bind
		at sun.nio.ch.Net.bind0(Native Method)
		at sun.nio.ch.Net.bind(Net.java:433)
		at sun.nio.ch.Net.bind(Net.java:425)
		at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
		at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
		at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:219)
		at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:1118)
		at org.apache.tomcat.util.net.AbstractJsseEndpoint.init(AbstractJsseEndpoint.java:224)
		at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:581)
		at org.apache.coyote.http11.AbstractHttp11Protocol.init(AbstractHttp11Protocol.java:68)
		at org.apache.catalina.connector.Connector.initInternal(Connector.java:993)
		... 13 more

Find the server.xml configuration file in the conf directory in the Tomcat directory and modify the Tomcat startup port in the Connector tag.

insert image description here

<Connector port="9080" protocol="HTTP/1.1"
        connectionTimeout="20000"
        redirectPort="8443" />

Problem 3: A flash of non-port problem

When you start Tomcat, it crashes immediately. No error information is found in the logs in the logs directory. This is probably because the Tomcat and JDK versions do not correspond. It is possible that your Tomcat is Tomcat 9 and your JDK is 1.7. For the correspondence between Tomcat and JDK versions, please refer to this article, Correspondence between Tomcat and JDK Versions, Features of Tomcat Versions

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to configure the character set of Tomcat server to utf-8 to completely solve the problem of Chinese garbled characters
  • How to solve the problem of a large amount of garbled characters when starting Tomcat
  • This article tells you how to solve the Tomcat garbled problem (very detailed!)

<<:  Introduction to using MySQL commands to create, delete, and query indexes

>>:  JavaScript to achieve dynamic table effect

Recommend

How to draw a vertical line between two div tags in HTML

Recently, when I was drawing an interface, I enco...

How to solve the problem of MySQL query character set mismatch

Find the problem I recently encountered a problem...

MySQL data insertion efficiency comparison

When inserting data, I found that I had never con...

Viewing and analyzing MySQL execution status

When you feel that there is a problem with MySQL ...

Detailed implementation plan of Vue front-end exporting Excel files

Table of contents 1. Technology Selection 2. Tech...

MySQL compression usage scenarios and solutions

Introduction Describes the use cases and solution...

Install CentOS system based on WindowsX Hyper-V

At present, most people who use Linux either use ...

MySQL 8.0.15 installation tutorial for Windows 64-bit

First go to the official website to download and ...

JS deep and shallow copy details

Table of contents 1. What does shallow copy mean?...

Implementation of navigation bar and drop-down menu in CSS

1. CSS Navigation Bar (1) Function of the navigat...

How to implement one-click deployment of nfs in linux

Server Information Management server: m01 172.16....

HTML table tag tutorial (17): table title vertical alignment attribute VALIGN

The table caption can be placed above or below th...

Which one should I choose between MySQL unique index and normal index?

Imagine a scenario where, when designing a user t...

mysql 8.0.12 winx64 download and installation tutorial

MySQL 8.0.12 download and installation tutorial f...