title: Failed to start component [NonLoginAuthenticator[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
body: <p>I am trying to build a SpringBoot application.</p>
  
  <pre><code>   package com.uni.authorize;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication
  public class AuthorizeApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(AuthorizeApplication.class, args);
      }
  
  }
  </code></pre>
  
  <p>But, when I try to run the app, it throws me the below error:</p>
  
  <pre><code>2020-03-28 20:39:36.765 ERROR 19071 --- [           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.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_242]
      at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_242]
      at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_242]
      at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) [na:1.8.0_242]
      at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.startup.Tomcat.start(Tomcat.java:468) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:107) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.&lt;init&gt;(TomcatWebServer.java:88) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:438) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:191) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:180) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:153) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) [spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at com.uni.authorize.AuthorizeApplication.main(AuthorizeApplication.java:10) [classes/: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.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:176) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5068) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_242]
      at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) [na:1.8.0_242]
      at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) [tomcat-embed-core-9.0.33.jar:9.0.33]
      ... 29 common frames omitted
  Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
      at org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1321) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.33.jar:9.0.33]
      ... 39 common frames omitted
  
  2020-03-28 20:39:36.775 ERROR 19071 --- [           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.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:1.8.0_242]
      at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[na:1.8.0_242]
      at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.startup.Tomcat.start(Tomcat.java:468) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:107) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.&lt;init&gt;(TomcatWebServer.java:88) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:438) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:191) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:180) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:153) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) [spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
      at com.uni.authorize.AuthorizeApplication.main(AuthorizeApplication.java:10) [classes/: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.33.jar:9.0.33]
      at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_242]
      at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) ~[na:1.8.0_242]
      at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      ... 21 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.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:1.8.0_242]
      at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[na:1.8.0_242]
      at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      ... 29 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.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:176) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5068) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_242]
      at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) ~[na:1.8.0_242]
      at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      ... 29 common frames omitted
  Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
      at org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1321) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.33.jar:9.0.33]
      ... 39 common frames omitted
  
  2020-03-28 20:39:36.779  INFO 19071 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
  2020-03-28 20:39:36.935  WARN 19071 --- [           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
  2020-03-28 20:39:37.037  INFO 19071 --- [           main] ConditionEvaluationReportLoggingListener : 
  
  Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
  2020-03-28 20:39:37.143 ERROR 19071 --- [           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:1321)
  
  The following method did not exist:
  
      javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
  
  The method's class, javax.servlet.ServletContext, is available from the following locations:
  
      jar:file:/home/talha/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar!/javax/servlet/ServletContext.class
      jar:file:/home/talha/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.33/tomcat-embed-core-9.0.33.jar!/javax/servlet/ServletContext.class
  
  It was loaded from the following location:
  
      file:/home/talha/.m2/repository/javax/servlet/servlet-api/2.5/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>my current pom.xml file is as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.2.6.RELEASE&lt;/version&gt;
          &lt;relativePath /&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.uni&lt;/groupId&gt;
      &lt;artifactId&gt;authorize&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;name&gt;authorize&lt;/name&gt;
      &lt;description&gt;API for user registration and login with validation&lt;/description&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;!-- https://mvnrepository.com/artifact/com.sun.mail/javax.mail --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.mail&lt;/groupId&gt;
              &lt;artifactId&gt;javax.mail&lt;/artifactId&gt;
              &lt;version&gt;1.6.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.h2database&lt;/groupId&gt;
              &lt;artifactId&gt;h2&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-mongodb --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-mongodb&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
              &lt;artifactId&gt;spring-data-mongodb&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-core&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;!-- https://mvnrepository.com/artifact/joda-time/joda-time --&gt;
           &lt;dependency&gt;
              &lt;groupId&gt;joda-time&lt;/groupId&gt;
              &lt;artifactId&gt;joda-time&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
              &lt;artifactId&gt;gson&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.googlecode.jsontoken&lt;/groupId&gt;
              &lt;artifactId&gt;jsontoken&lt;/artifactId&gt;
              &lt;version&gt;1.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Thanks for using https://jar-download.com  --&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
                      &lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;finalName&gt;authrize&lt;/finalName&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>This application is for login and registrtaion, but when i try creating token for login i get the error mentioned above.
  My CreateToken code is as below:</p>
  
  <pre><code>package com.uni.authorize.service;
  
  import java.security.InvalidKeyException;
  import java.security.SignatureException;
  import java.util.List;
  
  import org.joda.time.DateTime;
  import org.joda.time.Instant;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  
  import com.google.gson.JsonObject;
  import com.uni.authorize.model.TokenKeys;
  import com.uni.authorize.pojo.TokenObject;
  import com.uni.authorize.repository.TokenKeysRepository;
  import com.uni.authorize.service.CreateToken;
  
  import net.oauth.jsontoken.JsonToken;
  import net.oauth.jsontoken.crypto.HmacSHA256Signer;
  
  public class CreateToken {
  
      private static final Logger LOGGER = LoggerFactory.getLogger(CreateToken.class);
  
      private static final String ISSUER = "UnI United Tech";
  
      @Autowired
      TokenKeysRepository tokenKeyRepository;
  
      public TokenObject createToken(String userId) {
  
          List&lt;TokenKeys&gt; tokenList = tokenKeyRepository.findAll();
          TokenKeys tokenKeys = tokenList.get(0);
  
          long accessTokenValidity = tokenKeys.getAccessTokenValidity();
          long refreshTokenValidiry = tokenKeys.getRefreshTokenValidity();
  
          String accessTokenKey = tokenKeys.getAccessKey();
  
          String refreshTokenKey = tokenKeys.getRefreshKey();
  
          String accessToken = generateAccessToken(userId, accessTokenKey, accessTokenValidity);
          String refreshToken = generateRefreshToken(userId, refreshTokenKey, refreshTokenValidiry);
  
          TokenObject tokenObject = new TokenObject();
  
          tokenObject.setAccess_token(accessToken);
          tokenObject.setRefresh_token(refreshToken);
          tokenObject.setToken_type("bearer");
          tokenObject.setExpires_in(accessTokenValidity);
          tokenObject.setScope("read write trust");
          return tokenObject;
      }
  
      private String generateAccessToken(String userId, String accessTokenKey, long accessTokenValidity) {
  
          HmacSHA256Signer signer;
  
          try {
              signer = new HmacSHA256Signer(ISSUER, null, accessTokenKey.getBytes());
          } catch (InvalidKeyException e) {
              throw new RuntimeException(e);
          }
  
          // Configure JSON token
          JsonToken token = new net.oauth.jsontoken.JsonToken(signer);
          // token.setAudience(AUDIENCE);
  
          DateTime dateTime = new DateTime();
  
          long dateTimeMillis = dateTime.getMillis();
  
  //      DateTime currentTimeDateTime = new DateTime(dateTimeMillis);
  //      DateTime expiryTimeDateTime = new DateTime(dateTimeMillis + accessTokenValidity);
  
          Instant currentTimeInstant = new org.joda.time.Instant(dateTimeMillis);
          Instant expirationTimeInstant = new org.joda.time.Instant(dateTimeMillis + accessTokenValidity);
  
          LOGGER.debug("Current Time Instant" + currentTimeInstant);
          LOGGER.debug("Expiration Tine Instant" + expirationTimeInstant);
  
          token.setIssuedAt(currentTimeInstant);
          token.setExpiration(expirationTimeInstant);
  
          // Configure request object, which provides information of the item
          JsonObject request = new JsonObject();
          request.addProperty("userId", userId);
  
          JsonObject payload = token.getPayloadAsJsonObject();
          payload.add("info", request);
  
          try {
              return token.serializeAndSign();
          } catch (SignatureException e) {
              throw new RuntimeException(e);
          }
      }
  
      private String generateRefreshToken(String userId, String refreshTokenKey, long refreshTokenValidiry) {
          HmacSHA256Signer signer;
  
          try {
              signer = new HmacSHA256Signer(ISSUER, null, refreshTokenKey.getBytes());
          } catch (InvalidKeyException e) {
              throw new RuntimeException(e);
          }
  
          // Configure JSON token
          JsonToken token = new net.oauth.jsontoken.JsonToken(signer);
          // token.setAudience(AUDIENCE);
  
          DateTime dateTime = new DateTime();
  
          long dateTimeMillis = dateTime.getMillis();
  
  //      DateTime currentTimeDateTime = new DateTime(dateTimeMillis);
  //      DateTime expiryTimeDateTime = new DateTime(dateTimeMillis + refreshTokenValidiry);
  
          Instant currentTimeInstant = new org.joda.time.Instant(dateTimeMillis);
          Instant expirationTimeInstant = new org.joda.time.Instant(dateTimeMillis + refreshTokenValidiry);
  
          LOGGER.debug("Current Time Instant" + currentTimeInstant);
          LOGGER.debug("Expiration Tine Instant" + expirationTimeInstant);
  
          token.setIssuedAt(currentTimeInstant);
          token.setExpiration(expirationTimeInstant);
  
          // Configure request object, which provides information of the item
          JsonObject request = new JsonObject();
          request.addProperty("userId", userId);
  
          JsonObject payload = token.getPayloadAsJsonObject();
          payload.add("info", request);
  
          try {
              return token.serializeAndSign();
          } catch (SignatureException e) {
              throw new RuntimeException(e);
          }
      }
  
  }
  </code></pre>
  
  <p>If i remove the following dependency and the class CreateToke the application runs fine , but as the CreateToken is removed the token is not created.The following are the dependencies which i remove for the code to run:</p>
  
  <pre><code> &lt;dependency&gt;
              &lt;groupId&gt;joda-time&lt;/groupId&gt;
              &lt;artifactId&gt;joda-time&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
              &lt;artifactId&gt;gson&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.googlecode.jsontoken&lt;/groupId&gt;
              &lt;artifactId&gt;jsontoken&lt;/artifactId&gt;
              &lt;version&gt;1.0&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>Please let me know where am going wrong.
  <strong>Thanks in advance for helping</strong></p>