P
P
piatachki2017-12-04 18:02:11
Java
piatachki, 2017-12-04 18:02:11

How to run a default Spring boot 2.x application?

Hello.
I generate an application skeleton on start.spring.io (Java, Maven, Boot 2.0.0 M7). Without any edits, I try to run it and get the following stack trace:

Sheet
2017-12-04 17:44:49.150  WARN 19558 --- [           main] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start reactive web server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NettyReactiveWebServerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerConfiguration$ReactorNettyAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'defaultReactiveWebServerCustomizer' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'defaultReactiveWebServerCustomizer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'server-org.springframework.boot.autoconfigure.web.ServerProperties': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
2017-12-04 17:44:49.155  INFO 19558 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2017-12-04 17:44:49.162 ERROR 19558 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.context.ApplicationContextException: Unable to start reactive web server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NettyReactiveWebServerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerConfiguration$ReactorNettyAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'defaultReactiveWebServerCustomizer' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'defaultReactiveWebServerCustomizer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'server-org.springframework.boot.autoconfigure.web.ServerProperties': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
  at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onRefresh(ReactiveWebServerApplicationContext.java:72) ~[spring-boot-2.0.0.M7.jar:2.0.0.M7]
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-5.0.2.RELEASE.jar:5.0.2.RELEASE]
  at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:57) ~[spring-boot-2.0.0.M7.jar:2.0.0.M7]
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:751) [spring-boot-2.0.0.M7.jar:2.0.0.M7]
  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:387) [spring-boot-2.0.0.M7.jar:2.0.0.M7]
.....
  at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.createWebServer(ReactiveWebServerApplicationContext.java:95) ~[spring-boot-2.0.0.M7.jar:2.0.0.M7]
  at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onRefresh(ReactiveWebServerApplicationContext.java:69) ~[spring-boot-2.0.0.M7.jar:2.0.0.M7]
  ... 8 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'defaultReactiveWebServerCustomizer' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'defaultReactiveWebServerCustomizer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'server-org.springframework.boot.autoconfigure.web.ServerProperties': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
  at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:729) ~[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE]
  at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:470) ~[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE]
...
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702) ~[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583) ~[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE]
  ... 16 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'server-org.springframework.boot.autoconfigure.web.ServerProperties': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:591) ~[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE]
....
  at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:721) ~[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE]
  ... 33 common frames omitted
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
  at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:33) ~[hibernate-validator-6.0.5.Final.jar:6.0.5.Final]
  at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:296) ~[validation-api-2.0.0.Final.jar:na]
  at org.springframework.boot.validation.MessageInterpolatorFactory.getObject(MessageInterpolatorFactory.java:53) ~[spring-boot-2.0.0.M7.jar:2.0.0.M7]
  at org.springframework.boot.context.properties.ValidatedLocalValidatorFactoryBean.<init>(ValidatedLocalValidatorFactoryBean.java:35) ~[spring-boot-2.0.0.M7.jar:2.0.0.M7]
  at org.springframework.boot.context.properties.ConfigurationPropertiesBinderBuilder.determineValidator(ConfigurationPropertiesBinderBuilder.java:150) ~[spring-boot-2.0.0.M7.jar:2.0.0.M7]
  at org.springframework.boot.context.properties.ConfigurationPropertiesBinderBuilder.build(ConfigurationPropertiesBinderBuilder.java:137) ~[spring-boot-2.0.0.M7.jar:2.0.0.M7]
  at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.getBinder(ConfigurationPropertiesBindingPostProcessor.java:196) ~[spring-boot-2.0.0.M7.jar:2.0.0.M7]
  at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:167) ~[spring-boot-2.0.0.M7.jar:2.0.0.M7]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:423) ~[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702) ~[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583) ~[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE]
  ... 43 common frames omitted

As I understand it, NoClassDefFoundError indicates a dependency problem. I looked around, it seems, the entire Internet and open issue in the M7 boot, but I did not find anything similar. Moreover, judging by the number of tutorials on Spring Boot 2, everything works without problems for the whole world. I have the same exception on the entire boot 2.x branch and on snapshots. There are no problems on boot 1.x.
Explicitly specifying the Hibernate Validator dependency does not solve the problem.
Tell me, please, what could be the problem. I would be grateful for any hint.
PS. The composition of dependencies does not affect the situation. Even if I do not include any components (web, jpa, etc.), I still get the specified exception

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2017-12-05
@zolt85

NoClassDefFoundError indicates that the class could not be found in the application's classpath at the time the code was executed. Those. it is present at compile time, but not available at run time. Have a look at runtime and compile dependencies. I think if you put your "skeleton" on Github and give people a link, you will quickly be pointed to the cause of the error.

V
Vladislav, 2018-09-22
@Div100

Probably it was necessary to do maven reimport. Then clean install. Perhaps there was some kind of glitch.
In general, install a plugin or use dependency hiearchy (maven helper seems to be under IDEA), and there you can search for this class in some lib, is it there, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question