Exception sending context initialized event to listener instance of class [

Everything was working moments ago but suddenly getting the below error. I tried undo the stuffs I could remember but still same issue. Please help

2020-05-27 22:55:46.188  INFO 12412 --- [  restartedMain]
 dev-webpack                              : Running webpack to compile frontend resources. This may take a moment, please stand by...
2020-05-27 22:55:47.352 ERROR 12412 --- [  restartedMain]
 o.a.c.c.C.[Tomcat]
.[localhost]
.
[/]       : Exception sending context initialized event to listener instance of class [com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener]


java.lang.RuntimeException: Unable to initialize Vaadin DevModeHandler
	at com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener.contextInitialized(VaadinServletContextInitializer.java:352) ~[vaadin-spring-12.2.0.jar:na]

	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4684) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5147) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_131]

	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) [na:1.8.0_131]

	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_131]

	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) [na:1.8.0_131]

	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.apache.catalina.startup.Tomcat.start(Tomcat.java:468) [tomcat-embed-core-9.0.35.jar:9.0.35]

	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:437) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:191) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:176) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:158) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) [spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]

	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at com.gmail.srinivasa.Application.main(Application.java:14) [classes/:na]

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]

	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]

	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]

	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.3.0.RELEASE.jar:2.3.0.RELEASE]

Caused by: javax.servlet.ServletException: java.lang.IllegalStateException: Webpack exited prematurely
	at com.vaadin.flow.server.startup.DevModeInitializer.initDevModeHandler(DevModeInitializer.java:335) ~[flow-server-2.2.0.jar:2.2.0]

	at com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener.contextInitialized(VaadinServletContextInitializer.java:349) ~[vaadin-spring-12.2.0.jar:na]

	... 44 common frames omitted
Caused by: java.lang.IllegalStateException: Webpack exited prematurely
	at com.vaadin.flow.server.DevModeHandler.<init>(DevModeHandler.java:220) ~[flow-server-2.2.0.jar:2.2.0]

	at com.vaadin.flow.server.DevModeHandler.createInstance(DevModeHandler.java:318) ~[flow-server-2.2.0.jar:2.2.0]

	at com.vaadin.flow.server.DevModeHandler.start(DevModeHandler.java:268) ~[flow-server-2.2.0.jar:2.2.0]

	at com.vaadin.flow.server.DevModeHandler.start(DevModeHandler.java:245) ~[flow-server-2.2.0.jar:2.2.0]

	at com.vaadin.flow.server.startup.DevModeInitializer.initDevModeHandler(DevModeInitializer.java:331) ~[flow-server-2.2.0.jar:2.2.0]

	... 45 common frames omitted

2020-05-27 22:55:47.359 ERROR 12412 --- [  restartedMain]
 o.apache.catalina.core.StandardContext   : One or more listeners failed to start. Full details will be found in the appropriate container log file
2020-05-27 22:55:47.360 ERROR 12412 --- [  restartedMain]
 o.apache.catalina.core.StandardContext   : Context [] startup failed due to previous errors
2020-05-27 22:55:47.364  WARN 12412 --- [  restartedMain]
 o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT]
 appears to have started a thread named [Thread-138]
 but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.net.DualStackPlainSocketImpl.accept0(Native Method)
 java.net.DualStackPlainSocketImpl.socketAccept(DualStackPlainSocketImpl.java:131)
 java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409)
 java.net.PlainSocketImpl.accept(PlainSocketImpl.java:199)
 java.net.ServerSocket.implAccept(ServerSocket.java:545)
 java.net.ServerSocket.accept(ServerSocket.java:513)
 com.vaadin.flow.server.DevServerWatchDog$WatchDogServer.run(DevServerWatchDog.java:58)
 java.lang.Thread.run(Thread.java:748)
2020-05-27 22:55:47.624  INFO 12412 --- [  restartedMain]
 o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

2020-05-27 22:55:47.629  WARN 12412 --- [  restartedMain]
 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-05-27 22:55:47.631  INFO 12412 --- [  restartedMain]
 com.holonplatform.spring                 : Spring BeanFactory context scope unregistered [ClassLoader: org.springframework.boot.devtools.restart.classloader.RestartClassLoader@43b28928]

2020-05-27 22:55:47.638  INFO 12412 --- [  restartedMain]
 ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-05-27 22:55:47.640 ERROR 12412 --- [  restartedMain]
 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:161) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]

	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at com.gmail.srinivasa.Application.main(Application.java:14) [classes/:na]

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]

	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]

	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]

	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.3.0.RELEASE.jar:2.3.0.RELEASE]

Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:142) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:437) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:191) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:176) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:158) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	... 14 common frames omitted
Caused by: java.lang.IllegalStateException: StandardEngine[Tomcat]
.StandardHost[localhost]
.TomcatEmbeddedContext[] failed to start
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.rethrowDeferredStartupExceptions(TomcatWebServer.java:187) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]

	... 19 common frames omitted

Picked up JAVA_TOOL_OPTIONS: -Djava.vendor="New Oracle"
Picked up _JAVA_OPTIONS: -Xms256M -Xmx1024M

Process finished with exit code 0

I saw this issue too. Try to delete all generated directories and files

/target
/node_modules
package.json
package-lock.json
webpack.config.js
webpack.generated.js

Yes. It did the magic. But wondering what could have gone wrong with these and how deleting them works fine ?

And thanks a lot for your help.

I didn’t had the time to investigate and it only happened once.

Did you check if there is an issue? https://github.com/vaadin/flow/issues