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>

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

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

相关推荐
ajsbxi6 小时前
苍穹外卖学习记录
java·笔记·后端·学习·nginx·spring·servlet
记录成长java16 小时前
ServletContext,Cookie,HttpSession的使用
java·开发语言·servlet
长安初雪17 小时前
Request 和 Response 万字详解
计算机网络·servlet
A-bodgie21 小时前
Spring 中的 Environment 对象
java·后端·spring·servlet·springboot
笔墨登场说说2 天前
JDK 里面的线程池和Tomcat线程池的区别
java·servlet·tomcat
听潮阁3 天前
【SpringCloud详细教程】-01-一文了解微服务
开发语言·spring boot·spring cloud·servlet·java-ee·mybatis
阑梦清川3 天前
JavaEE初阶-----servlet-api,Maven创建项目,部署,打包,测试全过程
servlet·java-ee·maven
阑梦清川3 天前
JavaEE初阶--servlet篇(三)HttpServlet/response/request对应方法使用
java·servlet·java-ee
awonw4 天前
[java][基础]HTTP&Tomcat&Servlet
java·http·servlet·tomcat
长安初雪5 天前
Servlet 3.0 注解开发
servlet