博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang
阅读量:6594 次
发布时间:2019-06-24

本文共 8459 字,大约阅读时间需要 28 分钟。

 

 

springboot 启动报错 ,缺少  public abstract String getVirtualServerName(); 该方法

换用 引入高版本servlet-api,包含getVirtualServerName()方法 3.1.0 含getVirtualServerName

 

 

17:39:20.040 - A child container failed during startjava.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost [localhost].StandardContext[]]        at java.util.concurrent.FutureTask.report(FutureTask.java:122)        at java.util.concurrent.FutureTask.get(FutureTask.java:192)        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:911)        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:890)        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403)        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)        at java.util.concurrent.FutureTask.run(FutureTask.java:266)        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)        at java.lang.Thread.run(Thread.java:745)Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)        ... 6 common frames omittedCaused by: org.apache.catalina.LifecycleException: Failed to start component [Pipeline[StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]]        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5088)        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)        ... 6 common frames omittedCaused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.authenticator.NonLoginAuthenticator[]]        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)        at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:170)        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)        ... 8 common frames omittedCaused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;        at org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1085)        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)        ... 10 common frames omitted17:39:20.041 - A child container failed during startjava.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]        at java.util.concurrent.FutureTask.report(FutureTask.java:122)        at java.util.concurrent.FutureTask.get(FutureTask.java:192)        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:911)        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:791)        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:356)        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:97)        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.
(TomcatEmbeddedServletContainer.java:83) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:530) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:176) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:535) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) at com.hpe.ebtce.services.open.Application.main(Application.java:40) 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.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58)Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)Caused by: org.apache.catalina.LifecycleException: A child container failed during start at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:890) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152) ... 6 common frames omitted

 

 

 

servlet-api.jar 是否含有 java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()
 
 

 

引入高版本servlet-api,包含getVirtualServerName()方法 3.1.0 含

 

javax.servlet
javax.servlet-api
3.1.0

 

 

切换 tomcat 版本 选择非默认版本 <tomcat.version>8.5.23</tomcat.version>

 

 

UTF-8
UTF-8
1.8
8.5.23
1.7.9
1.0.1

 

 

 

注释 <scope>provided</scope> 如果javax.servlet-api 不存在java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName() Ljava.lang.String
public abstract String getVirtualServerName();

 

javax.servlet
javax.servlet-api
3.1.0
javax.servlet.jsp
jsp-api
2.1

 

 maven compile provided 区别

 

对于scope=compile的情况(默认scope),也就是说这个项目在编译,测试,运行阶段都需要这个artifact对应的jar包在classpath中。
而对于scope=provided的情况,则可以认为这个provided是目标容器已经provide这个artifact。换句话说,它只影响到编译,测试阶段。在编译测试阶段,我们需要这个artifact对应的jar包在classpath中,而在运行阶段,假定目标的容器(比如我们这里的tomcat容器)已经提供了这个jar包,所以无需我们这个artifact对应的jar包了。

 

 

 

 

 

 

 

 

 

捐助开发者 

在兴趣的驱动下,写一个免费的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(支持支付宝和微信 以及扣扣群),没钱捧个人场,谢谢各位。

 

 
 
 谢谢您的赞助,我会做的更好!

转载地址:http://zwjio.baihongyu.com/

你可能感兴趣的文章
数据库--MyBatis的(insert,update,delete)三种批量操作
查看>>
谈谈Vue.js——vue-resource全攻略
查看>>
源路由 就是指定数据传输经过这个路由服务器
查看>>
关于计算一对亲和数的探索
查看>>
Codeforces Round #566 (Div. 2) C. Beautiful Lyrics
查看>>
SQL 在OPENQUERY中使用参数
查看>>
Yii2 配置yii2-redis扩展
查看>>
CentOS下搭建LNMP+WordPress+http2.0教程
查看>>
正则表达式
查看>>
github使用小知识点查阅
查看>>
手把手教你画嘴巴,以后再也不怕画嘴巴了
查看>>
Python数据挖掘与机器学习_通信信用风险评估实战(1)——读数据
查看>>
发个项目需求大家瞅瞅
查看>>
初识Svelte
查看>>
【查找算法】基于存储的查找算法(哈希查找)
查看>>
改用ServletRequestAttributes
查看>>
项目空隙
查看>>
LintCode 前序遍历和中序遍历树构造二叉树
查看>>
Electron入门教程
查看>>
ubuntu 14 server vsftp login incorrect 530
查看>>