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>

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

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

相关推荐
ernesto_ji18 小时前
Jenkins下载安装、构建部署到linux远程启动运行
linux·servlet·jenkins
书埋不住我21 小时前
java第三章
java·开发语言·servlet
运维老司机3 天前
jenkins离线安装插件
运维·servlet·jenkins
运维老司机3 天前
Jenkins更换主题颜色+登录页面LOGO图片
运维·servlet·jenkins
java小吕布4 天前
Java Servlet详解:Servlet的生命周期、请求处理与响应发送
java·开发语言·servlet
namedlock5 天前
Failed to create a temp file - Jenkins 无法创建任务
java·servlet·jenkins
ling-455 天前
Javaweb-day12(登录认证)
服务器·前端·servlet
龙仔7256 天前
麒麟系统下docker搭建jenkins
servlet·docker·jenkins
cuisidong19977 天前
Springmvc配置文件application.xml 和 spring-servlet.xml
xml·spring·servlet
路在脚下@8 天前
Springboot 的Servlet Web 应用、响应式 Web 应用(Reactive)以及非 Web 应用(None)的特点和适用场景
java·spring boot·servlet