jakarta.servlet.ServletException: Servlet[dispatcher]的Servlet.init()引发异常

最近在学习springMVC碰到的问题

问题

html 复制代码
类型 异常报告

消息 Servlet[dispatcher]的Servlet.init()引发异常

描述 服务器遇到一个意外的情况,阻止它完成请求。

例外情况

jakarta.servlet.ServletException: Servlet[dispatcher]的Servlet.init()引发异常
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:673)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
	org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)
	org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
	org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736)
	org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
	org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
	java.base/java.lang.Thread.run(Thread.java:842)
	根本原因。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'handlerAdapter' defined in com.lgm.config.MvcConfig: JSON Binding provider org.eclipse.yasson.JsonBindingProvider not found
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1762)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521)
	org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:961)
	org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:917)
	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584)
	org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:706)
	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:583)
	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:537)
	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:169)
	jakarta.servlet.GenericServlet.init(GenericServlet.java:143)
	jakarta.servlet.http.HttpServlet.init(HttpServlet.java:121)
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:673)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
	org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)
	org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
	org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736)
	org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
	org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
	java.base/java.lang.Thread.run(Thread.java:842)
根本原因。

jakarta.json.bind.JsonbException: JSON Binding provider org.eclipse.yasson.JsonBindingProvider not found
	jakarta.json.bind.spi.JsonbProvider.provider(JsonbProvider.java:97)
	jakarta.json.bind.JsonbBuilder.create(JsonbBuilder.java:86)
	org.springframework.http.converter.json.JsonbHttpMessageConverter.<init>(JsonbHttpMessageConverter.java:55)
	org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.<init>(AllEncompassingFormHttpMessageConverter.java:91)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.initMessageConverters(RequestMappingHandlerAdapter.java:571)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.afterPropertiesSet(RequestMappingHandlerAdapter.java:548)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1808)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1758)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521)
	org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:961)
	org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:917)
	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584)
	org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:706)
	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:583)
	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:537)
	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:169)
	jakarta.servlet.GenericServlet.init(GenericServlet.java:143)
	jakarta.servlet.http.HttpServlet.init(HttpServlet.java:121)
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:673)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
	org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)
	org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
	org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736)
	org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
	org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
	java.base/java.lang.Thread.run(Thread.java:842)
根本原因。

java.lang.ClassNotFoundException: org.eclipse.yasson.JsonBindingProvider
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1353)
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1165)
	java.base/java.lang.Class.forName0(Native Method)
	java.base/java.lang.Class.forName(Class.java:375)
	jakarta.json.bind.spi.JsonbProvider.provider(JsonbProvider.java:94)
	jakarta.json.bind.JsonbBuilder.create(JsonbBuilder.java:86)
	org.springframework.http.converter.json.JsonbHttpMessageConverter.<init>(JsonbHttpMessageConverter.java:55)
	org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.<init>(AllEncompassingFormHttpMessageConverter.java:91)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.initMessageConverters(RequestMappingHandlerAdapter.java:571)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.afterPropertiesSet(RequestMappingHandlerAdapter.java:548)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1808)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1758)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521)
	org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:961)
	org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:917)
	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584)
	org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:706)
	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:583)
	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:537)
	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:169)
	jakarta.servlet.GenericServlet.init(GenericServlet.java:143)
	jakarta.servlet.http.HttpServlet.init(HttpServlet.java:121)
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:673)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
	org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)
	org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
	org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736)
	org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
	org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
	java.base/java.lang.Thread.run(Thread.java:842)
):注意 主要问题的全部 stack 信息可以在 server logs 里查看

Apache Tomcat/10.1.23

由于搜索这个错误的时候很少,情况有很多种,搜到的基本上都不是我遇到的问题,幸好看到有个博友写的博客是遇到tomcat9升级tomcat10情况和我一样,试了试,结果真的解决了

解决办法

在pom.xml文件中添加相关依赖

xml 复制代码
		<dependency>
            <groupId>org.eclipse</groupId>
            <artifactId>yasson</artifactId>
            <version>3.0.0</version>
        </dependency>

添加这个依赖就完美解决了这个问题

记录一下比较少遇到的情况,方便以后自己

相关推荐
编程、小哥哥1 天前
在 Docker 中部署 Jenkins,并完成项目的构建和发布
servlet·docker·jenkins
weixin_537590452 天前
《Java编程入门官方教程》第八章练习答案
java·开发语言·servlet
Ttang234 天前
Tomcat原理(4)——尝试手动Servlet的实现
java·开发语言·servlet·java-ee·tomcat·intellij-idea
loop lee4 天前
计算机网络 - HTTP 协议和万维网
java·网络协议·servlet·tomcat
不修×蝙蝠4 天前
搭建Tomcat(四)---Servlet容器
java·服务器·servlet·tomcat·搭建resquest
像污秽一样5 天前
简易记事本开发-(SSM+Vue)
java·vue.js·spring boot·spring·servlet·maven·mybatis
计算机学无涯6 天前
Servlet学习中遇到的一些问题及解决
servlet
测试工程师成长之路6 天前
解锁 Jenkins 搭建全攻略
运维·servlet·jenkins
进击的编程浪人6 天前
jsp中的四个域对象(Spring MVC)
servlet
怒放de生命20107 天前
jenkins 出现 Jenkins: 403 No valid crumb was included in the request
java·servlet·jenkins