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

Linux file and user management practice

1. Display the files or directories in the /etc d...

Difference between src and href attributes

There is a difference between src and href, and t...

How to solve the mysql error 1033 Incorrect information in file: 'xxx.frm'

Problem Description 1. Database of the collection...

Detailed explanation of the solution to Tomcat's 404 error

The 404 problem occurs in the Tomcat test. The pr...

Detailed explanation of transaction isolation levels in MySql study notes

background When we talk about transactions, every...

JavaScript+html to implement front-end page sliding verification (2)

This article example shares the specific code of ...

js to realize the function of uploading pictures

The principle of uploading pictures on the front ...

Complete steps for vue dynamic binding icons

0 Differences between icons and images Icons are ...

Some thoughts and experience sharing on web page (website) design and production

First, before posting! Thanks again to I Want to S...

CentOS 6.4 MySQL 5.7.18 installation and configuration method graphic tutorial

The specific steps of installing mysql5.7.18 unde...

How to install MySQL and Redis in Docker

This article is based on the CentOS 7.3 system en...