当前位置:网站首页>[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
边栏推荐
- Kung Fu pays off, and learning is done
- Tianyi ty1208-z brush machine detailed tutorial (free to remove)
- Take you to the installation and simple use tutorial of the deveco studio compiler of harmonyos to create and run Hello world?
- 十條職場規則
- Adult adult adult
- Using swift language features, write a pseudo-random number generator casually
- Is it OK to open an account for online stock speculation? Is the fund safe?
- 2020-11_ Technical experience set
- 基于同步坐标变换的谐波电流检测
- Lambda表达式
猜你喜欢
剑指Offer03. 数组中重复的数字【简单】
Method overloading and rewriting
Attack and defense world mobile--ph0en1x-100
ncnn神經網絡計算框架在香柳丁派OrangePi 3 LTS開發板中的使用介紹
[ArcGIS user defined script tool] vector file generates expanded rectangular face elements
(latest version) WiFi distribution multi format + installation framework
Xctf mobile--app1 problem solving
idea将web项目打包成war包并部署到服务器上运行
阿里 & 蚂蚁自研 IDE
Eureka自我保护
随机推荐
Eureka self protection
初入职场,如何快速脱颖而出?
2021 autumn Information Security Experiment 1 (password and hiding technology)
Xctf mobile--app1 problem solving
lambda与匿名内部类的区别
Airflow installation jump pit
CNN MNIST handwriting recognition
Is it safe to open an account for online stock speculation? Who can answer
Tensorflow binary installation & Failure
Solve the problem of VI opening files with ^m at the end
Xctf mobile--rememberother problem solving
studio All flavors must now belong to a named flavor dimension. Learn more
Enter the length of three sides of the triangle through the user, and calculate the area of the triangle, where the length is a real number
JVM内存模型
Using swift language features, write a pseudo-random number generator casually
阿里 & 蚂蚁自研 IDE
Togaf certification self-study classic v2.0
If you can't learn, you have to learn. Jetpack compose writes an im app (II)
elastic_ L01_ summary
2.6 preliminary cognition of synergetic couroutines