当前位置:网站首页>[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
边栏推荐
- Alibaba is bigger than sending SMS (user microservice - message microservice)
- Oh my Zsh + TMUX installation
- Kotlin notes - popular knowledge points asterisk (*)
- Differences between initial, inherit, unset, revert and all
- 云计算未来 — 云原生
- Sword finger offer09 Implementing queues with two stacks
- Summary of error prone knowledge points: Calculation of define s (x) 3*x*x+1.
- Xctf mobile--app1 problem solving
- Display time with message interval of more than 1 minute in wechat applet discussion area
- temp
猜你喜欢

Public and private account sending prompt information (user microservice -- message microservice)

Node.js: express + MySQL的使用

强大的头像制作神器微信小程序

剑指Offer09. 用两个栈实现队列
![Sword finger offer04 Search in two-dimensional array [medium]](/img/c4/002c951f8d914aaea4f4133685ebd1.png)
Sword finger offer04 Search in two-dimensional array [medium]

Display time with message interval of more than 1 minute in wechat applet discussion area

(latest version) WiFi distribution multi format + installation framework

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

Cloud Computing future - native Cloud

Sword finger offer09 Implementing queues with two stacks
随机推荐
The future of cloud computing cloud native
Oh my Zsh + TMUX installation
Enable SASL authentication for memcached
TOGAF认证自学宝典V2.0
最新版盲盒商城thinkphp+uniapp
2020-09_ Shell Programming Notes
社交社区论坛APP超高颜值UI界面
Kung Fu pays off, and learning is done
2.7 overview of livedata knowledge points
最新版抽奖盲盒运营版
OpenStack节点地址改变
Bert running error: attributeerror: module'tensorflow contrib. tpu' has no attribute 'InputPipelineConfig'
Redhat5 installing socket5 proxy server
elastic_ L01_ summary
自抗扰控制器七-二阶 LADRC-PLL 结构设计
Sqoop1.4.4原生增量导入特性探秘
Using swift language features, write a pseudo-random number generator casually
记录自己vulnhub闯关记录
强大的头像制作神器微信小程序
Openstack node address change