The application does not start if spring-boot-devtools is a dependency in the application’s pom.xml.
(my application is not a clone but relevant parts are identical to the bookstore-demo)
Having this dependency leads to a dump. Removing the dependency makes the application work again:
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
[2m2024-05-18T17:00:28.986+02:00[0;39m [31mERROR[0;39m [35m30712[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [2m[0;39m[36mo.s.boot.SpringApplication [0;39m [2m:[0;39m Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getDataService' defined in class path resource [com/gork/VaadinApplicationConfiguration.class]: Failed to instantiate [com.gork.data.DataService]: Factory method 'getDataService' threw exception with message: class com.gork.data.Datx cannot be cast to class com.gork.data.Datx (com.gork.data.Datx is in unnamed module of loader 'app'; com.gork.data.Datx is in unnamed module of loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @71474478)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:648) ~[spring-beans-6.1.5.jar:6.1.5]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:485) ~[spring-beans-6.1.5.jar:6.1.5]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1335) ~[spring-beans-6.1.5.jar:6.1.5]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1165) ~[spring-beans-6.1.5.jar:6.1.5]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562) ~[spring-beans-6.1.5.jar:6.1.5]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) ~[spring-beans-6.1.5.jar:6.1.5]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.1.5.jar:6.1.5]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.1.5.jar:6.1.5]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.1.5.jar:6.1.5]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.1.5.jar:6.1.5]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975) ~[spring-beans-6.1.5.jar:6.1.5]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:962) ~[spring-context-6.1.5.jar:6.1.5]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624) ~[spring-context-6.1.5.jar:6.1.5]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:334) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-3.2.4.jar:3.2.4]
at com.gork.Application.main(Application.java:26) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[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:568) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) ~[spring-boot-devtools-3.2.4.jar:3.2.4]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.gork.data.DataService]: Factory method 'getDataService' threw exception with message: class com.gork.data.Datx cannot be cast to class com.gork.data.Datx (com.gork.data.Datx is in unnamed module of loader 'app'; com.gork.data.Datx is in unnamed module of loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @71474478)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:177) ~[spring-beans-6.1.5.jar:6.1.5]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644) ~[spring-beans-6.1.5.jar:6.1.5]
... 24 common frames omitted
Caused by: java.lang.ClassCastException: class com.gork.data.Datx cannot be cast to class com.gork.data.Datx (com.gork.data.Datx is in unnamed module of loader 'app'; com.gork.data.Datx is in unnamed module of loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @71474478)
at com.gork.data.DataService.createStorageManager(DataService.java:78) ~[classes/:na]
at com.gork.data.DataService.storageManager(DataService.java:42) ~[classes/:na]
at com.gork.VaadinApplicationConfiguration.getDataService(VaadinApplicationConfiguration.java:27) ~[classes/:na]
at com.gork.VaadinApplicationConfiguration$$SpringCGLIB$$0.CGLIB$getDataService$0(<generated>) ~[classes/:na]
at com.gork.VaadinApplicationConfiguration$$SpringCGLIB$$FastClass$$1.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258) ~[spring-core-6.1.5.jar:6.1.5]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-6.1.5.jar:6.1.5]
at com.gork.VaadinApplicationConfiguration$$SpringCGLIB$$0.getDataService(<generated>) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[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:568) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140) ~[spring-beans-6.1.5.jar:6.1.5]
... 25 common frames omitted
Note the ClassCastException mentioning two locations of the Datx-object, which is my root-Object:
class com.gork.data.Datx cannot be cast to class com.gork.data.Datx (com.gork.data.Datx is in unnamed module of loader 'app'; com.gork.data.Datx is in unnamed module of loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @71474478)
The application does not start if
spring-boot-devtools
is a dependency in the application’spom.xml
. (my application is not a clone but relevant parts are identical to the bookstore-demo)Having this dependency leads to a dump. Removing the dependency makes the application work again:
The full stack trace:
Note the
ClassCastException
mentioning two locations of theDatx
-object, which is my root-Object:class com.gork.data.Datx cannot be cast to class com.gork.data.Datx (com.gork.data.Datx is in unnamed module of loader 'app'; com.gork.data.Datx is in unnamed module of loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @71474478)