title: Caused by: java.lang.NoSuchMethodError: 'java.lang.String javax.servlet.ServletContext.getVirtualServerName()'
body: <p>I'm trying to create a Gradle project to register Eureka services. Main method configuration:</p>
  <pre><code>import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
  
  @SpringBootApplication
  @EnableEurekaServer
  public class EurekaServerApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(EurekaServerApplication.class, args);
      }
  
  }
  </code></pre>
  <p>I use this gradle configuration:</p>
  <pre><code>plugins {
      id 'org.springframework.boot' version '2.4.5'
      id 'io.spring.dependency-management' version '1.0.11.RELEASE'
      id 'java'
  }
  
  group = 'org.test'
  version = '0.0.1-SNAPSHOT'
  sourceCompatibility = '11'
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-eureka-client', version: '3.0.2'
      implementation group: 'org.springframework.cloud', name: 'spring-cloud-netflix-eureka-server', version: '3.0.2'
  }
  
  test {
      useJUnitPlatform()
  }
  </code></pre>
  <p>But when I compile the project I get this error:</p>
  <pre><code>2021-05-03 01:30:21.661  INFO 23396 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=de56758b-78fd-328a-9faf-0cacba840b49
  2021-05-03 01:30:22.798  INFO 23396 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
  2021-05-03 01:30:22.835  INFO 23396 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
  2021-05-03 01:30:22.837  INFO 23396 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.45]
  2021-05-03 01:30:23.045 ERROR 23396 --- [           main] org.apache.catalina.core.ContainerBase   : A child container failed during start
  
  java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [NonLoginAuthenticator[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
          at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
          at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
          at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:843) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
          at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
          at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.&lt;init&gt;(TomcatWebServer.java:104) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:450) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:199) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:159) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) ~[spring-context-5.3.6.jar!/:5.3.6]
          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:782) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:774) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:339) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.skyshop.server.EurekaServerApplication.main(EurekaServerApplication.java:12) ~[classes!/:na]
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
          at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
          at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[server-0.0.1-SNAPSHOT.jar:na]
          at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) ~[server-0.0.1-SNAPSHOT.jar:na]
          at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[server-0.0.1-SNAPSHOT.jar:na]
          at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[server-0.0.1-SNAPSHOT.jar:na]
  Caused by: org.apache.catalina.LifecycleException: Failed to start component [NonLoginAuthenticator[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
          at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:176) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5089) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
          at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
          at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.45.jar!/:na]
          ... 38 common frames omitted
  Caused by: java.lang.NoSuchMethodError: 'java.lang.String javax.servlet.ServletContext.getVirtualServerName()'
          at org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1355) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.45.jar!/:na]
          ... 48 common frames omitted
  
  2021-05-03 01:30:23.049 ERROR 23396 --- [           main] org.apache.catalina.core.ContainerBase   : A child container failed during start
  
  java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start
          at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
          at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
          at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.&lt;init&gt;(TomcatWebServer.java:104) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:450) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:199) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:159) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) ~[spring-context-5.3.6.jar!/:5.3.6]
          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:782) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:774) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:339) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329) ~[spring-boot-2.4.5.jar!/:2.4.5]
          at org.skyshop.server.EurekaServerApplication.main(EurekaServerApplication.java:12) ~[classes!/:na]
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
          at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
          at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[server-0.0.1-SNAPSHOT.jar:na]
          at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) ~[server-0.0.1-SNAPSHOT.jar:na]
          at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[server-0.0.1-SNAPSHOT.jar:na]
          at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[server-0.0.1-SNAPSHOT.jar:na]
  Caused by: org.apache.catalina.LifecycleException: A child container failed during start
          at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:928) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:843) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
          at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
          at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.45.jar!/:na]
          ... 30 common frames omitted
  Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [NonLoginAuthenticator[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
          at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
          at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
          at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) ~[tomcat-embed-core-9.0.45.jar!/:na]
          ... 38 common frames omitted
  Caused by: org.apache.catalina.LifecycleException: Failed to start component [NonLoginAuthenticator[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
          at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:176) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5089) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
          at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
          at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.45.jar!/:na]
          ... 38 common frames omitted
  Caused by: java.lang.NoSuchMethodError: 'java.lang.String javax.servlet.ServletContext.getVirtualServerName()'
          at org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1355) ~[tomcat-embed-core-9.0.45.jar!/:na]
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.45.jar!/:na]
          ... 48 common frames omitted
  
  2021-05-03 01:30:23.057  INFO 23396 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
  2021-05-03 01:30:23.070  WARN 23396 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
  2021-05-03 01:30:23.106  INFO 23396 --- [           main] ConditionEvaluationReportLoggingListener :
  
  Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
  2021-05-03 01:30:23.207 ERROR 23396 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :
  
  ***************************
  APPLICATION FAILED TO START
  ***************************
  
  Description:
  
  An attempt was made to call a method that does not exist. The attempt was made from the following location:
  
      org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1355)
  
  The following method did not exist:
  
      'java.lang.String javax.servlet.ServletContext.getVirtualServerName()'
  
  The method's class, javax.servlet.ServletContext, is available from the following locations:
  
      jar:file:/C:/Users/plte1219/Desktop/CJM/skyshop-registry/build/libs/server-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/servlet-api-2.5.jar!/javax/servlet/ServletContext.class
      jar:file:/C:/Users/plte1219/Desktop/CJM/skyshop-registry/build/libs/server-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/tomcat-embed-core-9.0.45.jar!/javax/servlet/ServletContext.class
  
  The class hierarchy was loaded from the following locations:
  
      javax.servlet.ServletContext: jar:file:/C:/Users/plte1219/Desktop/CJM/skyshop-registry/build/libs/server-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/servlet-api-2.5.jar!/
  
  
  Action:
  
  Correct the classpath of your application so that it contains a single, compatible version of javax.servlet.ServletContext
  </code></pre>
  <p>Do you know how I can fix this issue?</p>