Tomcat common exceptions and solution code examples

Tomcat common exceptions and solution code examples

The company project was developed in Java and the middleware was Tomcat. During the operation, some exceptions occurred in Tomcat. The exceptions and solutions are recorded as follows for reference only. (Continuously supplementing...)

Anomaly 1:

1. Log content

org.apache.coyote.http11.AbstractHttp11Processor.process Error parsing HTTP request header
Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
at org.apache.coyote.http11.AbstractNioInputBuffer.parseRequestLine(AbstractNioInputBuffer.java:233)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1017)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

2. Solution

Add the following line to the conf/catalina.properties file in the tomcat installation folder:

org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true

Exception 2:

1. Log content

com.alibaba.druid.stat.DruidStatService]unregister mbean error
javax.management.InstanceNotFoundException: com.alibaba.druid:type=DruidStatService
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1095)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.exclusiveUnregisterMBean(DefaultMBeanServerInterceptor.java:427)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.unregisterMBean(DefaultMBeanServerInterceptor.java:415)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.unregisterMBean(JmxMBeanServer.java:546)
	at com.alibaba.druid.stat.DruidStatService.unregisterMBean(DruidStatService.java:374)
	at com.alibaba.druid.stat.DruidDataSourceStatManager.removeDataSource(DruidDataSourceStatManager.java:202)
	at com.alibaba.druid.pool.DruidDataSource$2.run(DruidDataSource.java:1479)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.alibaba.druid.pool.DruidDataSource.unregisterMbean(DruidDataSource.java:1475)
	at com.alibaba.druid.pool.DruidDataSource.close(DruidDataSource.java:1434)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:354)
	at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:277)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:972)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:979)
	at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1006)
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:982)
	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:934)
	at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:583)
	at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:116)
	at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4900)
	at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5537)
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:221)
	at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1424)
	at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1413)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)

2. Solution

Modify the catalina.sh file in the bin directory of tomcat, and add JAVA_OPTS="-Ddruid.registerToSysProperty=true" between # OS specific support. $var _must_ be set to either true or false. and cygwin=false

Exception three:

1. Log content

INFO [http-nio-80-exec-16] org.apache.coyote.http11.AbstractHttp11Processor.process Error parsing HTTP request header
 Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
 java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
	at org.apache.coyote.http11.AbstractNioInputBuffer.parseRequestLine(AbstractNioInputBuffer.java:236)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1065)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

2. Solution

Modify the conf/server.xml in the tomcat installation folder. In <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" maxHttpHeaderSize ="10240" redirectPort="8443" />, the default value of maxHttpHeaderSize is 8*1024. You just need to adjust it to the value you need.

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:
  • SpringBoot project is packaged and published to external tomcat (solving various exceptions)
  • A solution to the abnormal exit of Tomcat caused by semaphore
  • Analysis and solution of abnormal problem of loading jar in tomcat
  • Causes and solutions for the exception getOutputStream() has already been called for this response in jsp under tomcat6
  • Error when starting tomcat: The proxy threw an exception: java.rmi.server.ExportException: Port already in use: 1099 Solution
  • Solve the problem that idea2020.2 encounters an error in the pom.xml file Maven plugin tomcat7
  • Solve the problem of IDEA configuring tomcat startup error
  • Solve the problem of error 404 when starting tomcat after importing ssm project into idea
  • Tomcat startup error: solution to java.util.zip.ZipException
  • Tomcat exception solution (Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986)

<<:  VUE introduces the implementation of using G2 charts

>>:  Common scenarios and avoidance methods for index failure in MySQL

Recommend

Automatically log out inactive users after login timeout in Linux

Method 1: Modify the .bashrc or .bash_profile fil...

Vuex implements simple shopping cart function

This article example shares the specific code of ...

How to install mysql6 initialization installation password under centos7

1. Stop the database server first service mysqld ...

Linux firewall status check method example

How to check the status of Linux firewall 1. Basi...

HTML multi-header table code

1. Multi-header table code Copy code The code is a...

Example of using store in vue3 to record scroll position

Table of contents Overall Effect Listen for conta...

Mysql delete duplicate data to keep the smallest id solution

Search online to delete duplicate data and keep t...

How to invert the implementation of a Bezier curve in CSS

First, let’s take a look at a CSS carousel animat...

How to remove the dividing line of a web page table

<br />How to remove the dividing lines of a ...

Open the Windows server port (take port 8080 as an example)

What is a Port? The ports we usually refer to are...

Summary of the three stages of visual designer growth

Many people have read this book: "Grow as a ...

Example of how to identify the user using a linux Bash script

It is often necessary to run commands with sudo i...

PostgreSQL materialized view process analysis

This article mainly introduces the process analys...