当前位置:网站首页>[problem exploration and solution of one or more filters or listeners failing to start]
[problem exploration and solution of one or more filters or listeners failing to start]
2022-07-03 12:45:00 【T.Mss】
1. Problem description :
Use IDEA As a development tool , Use Maven As a project management tool , To complete a web project After use Tomcat Start the project as a server , Report errors One or more filters failed to start perhaps org.apache.catalina.core.StandardContext.startInternal One or more listeners Boot failure , See the corresponding container log file for more details , The cause of the error should be consistent .
2. The root cause :
stay Project deployment and operation environment Next , project-dependent jar The package was not imported into Project deployment environment in , To put it bluntly, there is a lack of jar package
3. Possible reasons for this :
establish Maven Project time , no choice Maven The architecture provided , Create a normal Maven project , Add web Framework support leads to , The project created in this way IDEA Project dependencies will not be automatically added jar Package to WEB-INF/lib Catalog . So create web Project time , If you want to use Maven As a project management tool , Try to choose Maven The project architecture provided can avoid
4. terms of settlement :
Put the missing jar Just import the package ,WEB-INF New under the directory lib Folder , The right choice Add copy of-->Library File, Add all the required dependencies of the project . As shown in the figure below
Specific operation ( Aim at IDEA development tool )



summary :
As can be seen from the illustration , If there is a lack of lib Folder or yours classes Folder If there is no project dependency in the same level directory , In the environment after the project deployment ,java Classes cannot find dependencies jar Bag .
Therefore, the following problems will occur
1. If the project is configured with a listener Listener, Project startup will fail , Report errors org.apache.catalina.core.StandardContext.startInternal One or more listeners Boot failure , See the corresponding container log file for more details
2. If the project is configured with filters Filter, Project startup will fail , Report errors One or more filters failed to start
3. If the project is not configured with the above two , Then you need to rely on others when accessing jar Bag java The program will report an error ClassNotFoundException
because Lisenter and Filter It starts when the container starts , You need to rely on jar package , If you can't find it , The container will fail to start , Ordinary Java The program is called only when it is accessed for the first time , So I will make mistakes in the interview
-------------------------------- The following is the original article -----------------------------------
Problem description :
Make a character encoding filter . register xml after ,Tomcat start-up web The project prompts the following error message :
org.apache.catalina.core.StandardContext.startInternal One or more filters failed to start .
take web.xml The registration information annotation item in can work normally , So it is suspected that the problem is the filter
CharacterEncodingFilter.java
package com.shme.filter; import javax.servlet.*; import java.io.IOException; /** * @Desc Character encoding filter */ public class CharacterEncodingFilter implements Filter{ @Override public void init(FilterConfig filterConfig) throws ServletException { System.out.println("CharacterEncodingFilter Filter initialization "); } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // Set up utf-8 request.setCharacterEncoding("utf-8"); response.setContentType("text/html"); response.setCharacterEncoding("utf-8"); chain.doFilter(request,response); } @Override public void destroy() { System.out.println("CharacterEncodingFilter Filter destruction "); } }
web.xml (3.1 edition )
<!-- Character encoding filter --> <filter> <filter-name>charset</filter-name> <filter-class>com.shme.filter.CharacterEncodingFilter</filter-class> </filter> <filter-mapping> <filter-name>charset</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
terms of settlement :
reason :
Use Maven Create project ,IDEA Deploy to Tomcat Server time , In my development environment, there will be a chance to encounter non compilation java Under folder java Source file , Lead to tomcat When deploying a project , Filter Need to start first , stay web.xml When looking for mappings in , In the project file Filter The implementation class was not compiled , That's why it's wrong .
terms of settlement : Refer to another article by the author A kind of Maven Do not compile when the project starts java File solutions - juyss - Blog Garden
边栏推荐
- [ManageEngine] the role of IP address scanning
- The solution to change the USB flash disk into a space of only 2m
- Apache Mina Development Manual
- temp
- [ArcGIS user defined script tool] vector file generates expanded rectangular face elements
- 社交社区论坛APP超高颜值UI界面
- Wechat applet pages always report errors when sending values to the background. It turned out to be this pit!
- Sword finger offer04 Search in two-dimensional array [medium]
- Summary of error prone knowledge points: Calculation of define s (x) 3*x*x+1.
- The upward and downward transformation of polymorphism
猜你喜欢

云计算未来 — 云原生

ncnn神經網絡計算框架在香柳丁派OrangePi 3 LTS開發板中的使用介紹

Eureka自我保护

(最新版) Wifi分销多开版+安装框架

剑指Offer03. 数组中重复的数字【简单】

With pictures and texts, summarize the basic review of C language in detail, so that all kinds of knowledge points are clear at a glance?

Xctf mobile--rememberother problem solving

电压环对 PFC 系统性能影响分析

Xctf mobile--app1 problem solving

Wechat applet pages always report errors when sending values to the background. It turned out to be this pit!
随机推荐
Sword finger offer10- I. Fibonacci sequence
强大的头像制作神器微信小程序
Simple use and precautions of kotlin's array array and set list
GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈
剑指Offer03. 数组中重复的数字【简单】
TOGAF认证自学宝典V2.0
Node.js: express + MySQL的使用
The future of cloud computing cloud native
Exploration of sqoop1.4.4 native incremental import feature
Swift5.7 extend some to generic parameters
ImportError: No module named examples. tutorials. mnist
Comprehensive evaluation of double chain notes · Siyuan notes: advantages, disadvantages and evaluation
Recovery of website address and method of Amazon account login two-step verification failure caused by mobile phone number becoming empty
01_ Using the concurrent tool class library, is thread safety safe
Drop down refresh conflicts with recyclerview sliding (swiperefreshlayout conflicts with recyclerview sliding)
剑指Offer04. 二维数组中的查找【中等】
Kung Fu pays off, and learning is done
flinksql是可以直接客户端建表读mysql或是kafka数据,但是怎么让它自动流转计算起来呢?
(最新版) Wifi分销多开版+安装框架
Using swift language features, write a pseudo-random number generator casually