embedded.EmbeddedServletContainerException: Unable to start embedded Jetty servlet container

文章描述了一个在启动SpringBoot应用时遇到的错误,具体是由于尝试启动嵌入式的JettyServlet容器失败导致的。异常信息显示为NullPointerException,问题根源在于config.getServletContext()为空,进一步调查发现是jetty包的版本与其他项目不一致。通过更新jetty的版本,成功解决了这个问题,使应用能够正常启动。
摘要由CSDN通过智能技术生成

报错
在这里插入图片描述

org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Jetty servlet container
	at org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainer.start(JettyEmbeddedServletContainer.java:163)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:297)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:145)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
	at com.xuanwu.ump.web.StartServer.main(StartServer.java:26)
Caused by: MultiException[javax.servlet.ServletException: java.lang.NullPointerException, javax.servlet.ServletException: default==org.eclipse.jetty.servlet.DefaultServlet@5c13d641{jsp=null,order=1,inst=true,async=true,src=EMBEDDED:null,STARTED}]
	at org.eclipse.jetty.util.MultiException.ifExceptionThrow(MultiException.java:122)
	at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:776)
	at org.springframework.boot.context.embedded.jetty.JettyEmbeddedWebAppContext$JettyEmbeddedServletHandler.deferredInitialize(JettyEmbeddedWebAppContext.java:46)
	at org.springframework.boot.context.embedded.jetty.JettyEmbeddedWebAppContext.deferredInitialize(JettyEmbeddedWebAppContext.java:36)
	at org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainer.handleDeferredInitialize(JettyEmbeddedServletContainer.java:207)
	at org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainer.start(JettyEmbeddedServletContainer.java:138)
	... 10 more
	Suppressed: javax.servlet.ServletException: java.lang.NullPointerException
		at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.init(WebSocketUpgradeFilter.java:461)
		at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:140)
		at org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$0(ServletHandler.java:750)
		at org.eclipse.jetty.servlet.ServletHandler$$Lambda$43/371605426.accept(Unknown Source)
		at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
		at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:742)
		at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
		at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:774)
		... 14 more
	Caused by: java.lang.NullPointerException
		at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.init(WebSocketUpgradeFilter.java:398)
		... 21 more
	Suppressed: javax.servlet.ServletException: default==org.eclipse.jetty.servlet.DefaultServlet@5c13d641{jsp=null,order=1,inst=true,async=true,src=EMBEDDED:null,STARTED}
		at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:650)
		at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:415)
		at org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$0(ServletHandler.java:750)
		at org.eclipse.jetty.servlet.ServletHandler$$Lambda$43/371605426.accept(Unknown Source)
		at java.util.stream.StreamSpliterators$WrappingSpliterator$$Lambda$46/1989511207.accept(Unknown Source)
		at java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:352)
		at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
		at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
		at java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)
		at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:743)
		at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
		at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:774)
		... 14 more
	Caused by: java.lang.NullPointerException
		at org.eclipse.jetty.servlet.DefaultServlet.initContextHandler(DefaultServlet.java:359)
		at org.eclipse.jetty.servlet.DefaultServlet.init(DefaultServlet.java:168)
		at javax.servlet.GenericServlet.init(GenericServlet.java:244)
		at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:632)
		... 25 more
	[CIRCULAR REFERENCE:javax.servlet.ServletException: java.lang.NullPointerException]

二月 15, 2023 10:15:39 上午 org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext doClose
信息: Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@56e07a08: startup date [Wed Feb 15 10:14:14 CST 2023]; root of context hierarchy
二月 15, 2023 10:15:39 上午 org.springframework.jmx.export.annotation.AnnotationMBeanExporter destroy
信息: Unregistering JMX-exposed beans on shutdown
二月 15, 2023 10:15:39 上午 org.springframework.jmx.export.annotation.AnnotationMBeanExporter unregisterBeans
信息: Unregistering JMX-exposed beans
二月 15, 2023 10:15:39 上午 com.xuanwu.ump.web.job.TaskExecutor shutdown
信息: Shutting down ExecutorService 'taskExecutor'
二月 15, 2023 10:15:39 上午 org.apache.commons.dbcp2.BasicDataSource close
警告: Failed to unregister the JMX name: org.apache.commons.dbcp2:name=listDataSource,type=BasicDataSource
javax.management.InstanceNotFoundException: org.apache.commons.dbcp2:name=listDataSource,type=BasicDataSource
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1095)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.exclusiveUnregisterMBean(DefaultMBeanServerInterceptor.java:427)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.unregisterMBean(DefaultMBeanServerInterceptor.java:415)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.unregisterMBean(JmxMBeanServer.java:546)
	at org.apache.commons.dbcp2.BasicDataSource.close(BasicDataSource.java:1917)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:364)
	at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:287)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:583)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:555)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:957)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:516)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:964)
	at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1034)
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1009)
	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958)
	at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750)
	at

排查思路:定位到空指针异常的地方,发现这里config.getServletContext()为空,在这里插入图片描述
configuration也为空,正常来讲configuration应该是启动容器注入,不应该为空在这里插入图片描述
所以定位到包,发现包的版本与其他项目的版本不一致在这里插入图片描述
定位maven,发现是jetty包下的,所以修改jetty版本在这里插入图片描述
顺利启动

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值