当前位置:网站首页>[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
边栏推荐
- GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈
- Solve the problem of VI opening files with ^m at the end
- What is more elegant for flutter to log out and confirm again?
- Applet wxss introduction
- Glide 4.6.1 API initial
- Official website of Unicode query
- Glide question you cannot start a load for a destroyed activity
- Export the entire Oracle Database
- 2.6 preliminary cognition of synergetic couroutines
- Eureka self protection
猜你喜欢

Differences between initial, inherit, unset, revert and all

2.8 overview of ViewModel knowledge

【ArcGIS自定义脚本工具】矢量文件生成扩大矩形面要素

TOGAF认证自学宝典V2.0

Use bloc to build a page instance of shutter

initial、inherit、unset、revert和all的区别

社交社区论坛APP超高颜值UI界面
![[download attached] password acquisition tool lazagne installation and use](/img/21/eccf87ad9946d4177b600d96e17322.png)
[download attached] password acquisition tool lazagne installation and use

Togaf certification self-study classic v2.0

Method overloading and rewriting
随机推荐
Kotlin notes - popular knowledge points asterisk (*)
2020-11_ Technical experience set
CNN MNIST handwriting recognition
Display time with message interval of more than 1 minute in wechat applet discussion area
十条职场规则
2020-10_ Development experience set
initial、inherit、unset、revert和all的区别
剑指Offer06. 从尾到头打印链表
初入职场,如何快速脱颖而出?
Sword finger offer04 Search in two-dimensional array [medium]
剑指Offer03. 数组中重复的数字【简单】
启用MemCached的SASL认证
【ArcGIS自定义脚本工具】矢量文件生成扩大矩形面要素
Oh my Zsh + TMUX installation
Eureka self protection
2.9 overview of databinding knowledge points
Using swift language features, write a pseudo-random number generator casually
1-1 token
Is it OK to open an account for online stock speculation? Is the fund safe?
【计网】第三章 数据链路层(2)流量控制与可靠传输、停止等待协议、后退N帧协议(GBN)、选择重传协议(SR)