I am trying to run spring boot application but i am getting an exception. I have tried many answers like mvn dependency:purge-local-repository
and then running mvn spring-boot:run
, updating spring boot 2 versions, etc but none is resolving the issue as I am getting below exception
2019-12-05 00:06:00.787 INFO 19840 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-12-05 00:06:00.791 WARN 19840 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [pool-1-thread-1] but has failed to stop it. This is very likely to create a memory leak. Stack tr
ace of thread:
java.base@11.0.5/jdk.internal.misc.Unsafe.park(Native Method)
java.base@11.0.5/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:234)
java.base@11.0.5/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2123)
java.base@11.0.5/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)
java.base@11.0.5/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
java.base@11.0.5/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
java.base@11.0.5/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
java.base@11.0.5/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java.base@11.0.5/java.lang.Thread.run(Thread.java:834)
2019-12-05 00:06:00.793 WARN 19840 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [pool-1-thread-2] but has failed to stop it. This is very likely to create a memory leak. Stack tr
ace of thread:
java.base@11.0.5/jdk.internal.misc.Unsafe.park(Native Method)
java.base@11.0.5/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
java.base@11.0.5/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2081)
java.base@11.0.5/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1177)
java.base@11.0.5/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
java.base@11.0.5/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
java.base@11.0.5/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
java.base@11.0.5/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java.base@11.0.5/java.lang.Thread.run(Thread.java:834)
2019-12-05 00:06:00.795 WARN 19840 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [HikariPool-1 housekeeper] but has failed to stop it. This is very likely to create a memory leak.
Stack trace of thread:
java.base@11.0.5/jdk.internal.misc.Unsafe.park(Native Method)
java.base@11.0.5/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:234)
java.base@11.0.5/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2123)
java.base@11.0.5/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)
java.base@11.0.5/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
java.base@11.0.5/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
java.base@11.0.5/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
java.base@11.0.5/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java.base@11.0.5/java.lang.Thread.run(Thread.java:834)
2019-12-05 00:06:00.798 WARN 19840 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [HikariPool-1 connection adder] but has failed to stop it. This is very likely to create a memory
leak. Stack trace of thread:
java.base@11.0.5/java.net.SocketInputStream.socketRead0(Native Method)
java.base@11.0.5/java.net.SocketInputStream.socketRead(SocketInputStream.java:115)
java.base@11.0.5/java.net.SocketInputStream.read(SocketInputStream.java:168)
java.base@11.0.5/java.net.SocketInputStream.read(SocketInputStream.java:140)
java.base@11.0.5/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:448)
java.base@11.0.5/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:68)
java.base@11.0.5/sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1104)
java.base@11.0.5/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:823)
org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:140)
org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:109)
org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:67)
org.postgresql.core.PGStream.receiveChar(PGStream.java:306)
org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactoryImpl.java:405)
org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:94)
org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192)
org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
org.postgresql.Driver.makeConnection(Driver.java:454)
org.postgresql.Driver.connect(Driver.java:256)
com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:119)
com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:369)
com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:198)
com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:467)
com.zaxxer.hikari.pool.HikariPool.access$100(HikariPool.java:71)
com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:706)
com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:692)
java.base@11.0.5/java.util.concurrent.FutureTask.run(FutureTask.java:264)
java.base@11.0.5/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
java.base@11.0.5/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java.base@11.0.5/java.lang.Thread.run(Thread.java:834)
2019-12-05 00:06:00.804 WARN 19840 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web serve
r; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2019-12-05 00:06:00.805 INFO 19840 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'application'
2019-12-05 00:06:00.806 INFO 19840 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'security'
2019-12-05 00:06:00.807 INFO 19840 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2019-12-05 00:06:02.244 INFO 19840 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2019-12-05 00:06:02.261 INFO 19840 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-12-05 00:06:02.276 ERROR 19840 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
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:566) ~[na:na]
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:542) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:124) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:414) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:178) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
... 14 common frames omitted
Caused by: java.lang.IllegalArgumentException: Servlet must not be null
at org.springframework.util.Assert.notNull(Assert.java:198) ~[spring-core-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.boot.web.servlet.ServletRegistrationBean.getDescription(ServletRegistrationBean.java:171) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.web.servlet.RegistrationBean.onStartup(RegistrationBean.java:48) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:227) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:53) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5132) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
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.21.jar:9.0.21]
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.21.jar:9.0.21]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
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.21.jar:9.0.21]
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.21.jar:9.0.21]
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:456) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:105) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
... 19 common frames omitted
[WARNING]
java.lang.reflect.InvocationTargetException
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:542)
at java.lang.Thread.run (Thread.java:834)
Caused by: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh (ServletWebServerApplicationContext.java:155)
at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:543)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh (ServletWebServerApplicationContext.java:140)
at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:742)
at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:389)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:311)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:1213)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:1202)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:542)
at java.lang.Thread.run (Thread.java:834)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize (TomcatWebServer.java:124)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init> (TomcatWebServer.java:86)
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer (TomcatServletWebServerFactory.java:414)
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer (TomcatServletWebServerFactory.java:178)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer (ServletWebServerApplicationContext.java:179)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh (ServletWebServerApplicationContext.java:152)
at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:543)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh (ServletWebServerApplicationContext.java:140)
at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:742)
at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:389)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:311)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:1213)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:1202)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:542)
at java.lang.Thread.run (Thread.java:834)
Caused by: java.lang.IllegalArgumentException: Servlet must not be null
at org.springframework.util.Assert.notNull (Assert.java:198)
at org.springframework.boot.web.servlet.ServletRegistrationBean.getDescription (ServletRegistrationBean.java:171)
at org.springframework.boot.web.servlet.RegistrationBean.onStartup (RegistrationBean.java:48)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize (ServletWebServerApplicationContext.java:227)
at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup (TomcatStarter.java:53)
at org.apache.catalina.core.StandardContext.startInternal (StandardContext.java:5132)
at org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1384)
at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1374)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute (InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit (AbstractExecutorService.java:140)
at org.apache.catalina.core.ContainerBase.startInternal (ContainerBase.java:909)
at org.apache.catalina.core.StandardHost.startInternal (StandardHost.java:841)
at org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1384)
at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1374)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute (InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit (AbstractExecutorService.java:140)
at org.apache.catalina.core.ContainerBase.startInternal (ContainerBase.java:909)
at org.apache.catalina.core.StandardEngine.startInternal (StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal (StandardService.java:421)
at org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal (StandardServer.java:932)
at org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:183)
at org.apache.catalina.startup.Tomcat.start (Tomcat.java:456)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize (TomcatWebServer.java:105)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init> (TomcatWebServer.java:86)
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer (TomcatServletWebServerFactory.java:414)
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer (TomcatServletWebServerFactory.java:178)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer (ServletWebServerApplicationContext.java:179)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh (ServletWebServerApplicationContext.java:152)
at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:543)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh (ServletWebServerApplicationContext.java:140)
at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:742)
at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:389)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:311)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:1213)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:1202)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:542)
at java.lang.Thread.run (Thread.java:834)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 37.901 s
[INFO] Finished at: 2019-12-05T00:06:03+05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.6.RELEASE:run (default-cli) on project sample-project: An exception occurred while running. null: InvocationTargetException: Unable to start web server; nested exception is org.
springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat: Servlet must not be null -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
My main spring boot file is
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.client.RestTemplate;
@SpringBootApplication
@Configuration
@EnableAsync
public class SampleProject extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(SampleProject.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SampleProject.class);
}
}
I am using JDK 11.0.5. I was running this on my Google App Engine with JDK 8 and it was running fine but async calls weren't working as I was getting error below.
There was an unexpected error (type=Internal Server Error,
status=500). Async support must be enabled on a servlet and for all
filters involved in async request processing. This is done in Java
code using the Servlet API or by adding "true" to servlet and filter
declarations in web.xml.
Upon some research I found JDK8 on GAE doesn't support NIO so I am now working to migrate it to JDK 11.Any help would be greatly appreciated. Thanks!
Update: My Servlet Config file
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ServletConfig {
@Bean
public ServletRegistrationBean servletRegistrationBean() throws Exception {
ServletRegistrationBean registrationBean = new ServletRegistrationBean();
registrationBean.setLoadOnStartup(1);
registrationBean.setAsyncSupported(true);
return registrationBean;
}
}
After removing my Servlet config file which was probably conflicting I got below error
***************************
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.springframework.data.rest.core.support.UnwrappingRepositoryInvokerFactory.<init>(UnwrappingRepositoryInvokerFactory.java:57)
The following method did not exist:
org.springframework.plugin.core.PluginRegistry.of(Ljava/util/List;)Lorg/springframework/plugin/core/PluginRegistry;
The method's class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:
jar:file:/C:/Users/icurious/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class
It was loaded from the following location:
file:/C:/Users/icurious/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry
Disconnected from the target VM, address: '127.0.0.1:0', transport: 'socket'
Process finished with exit code 1
Best Solution
The failure is occurring because your application contains a
ServletRegistrationBean
with anull
Servlet
. This is caused by yourservletRegistrationBean
:When you create a
ServletRegistrationBean
you need to provide theServlet
that you want it to register. You can either do that by passing theServlet
into the constructor ofServletRegistrationBean
or by calling thesetServlet(Servlet)
method. For example, assuming that yourServlet
class is calledYourServlet
, you could do the following: