After a few days, the Java application stops working - spring-boot

I am writing a pet application in Java. Spring database Web.
I place all this on the server in separate docker containers.
The database is created in the docker-compose file
postgres-content:
image: postgres:14.1
container_name: content_db-v01
restart: unless-stopped
ports:
- "5532:5432"
environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=*****
volumes:
- /home/my-db/content_db:/var/first-prj/data/content
- ./sql/create_db_catalog.sql:/docker-entrypoint-initdb.d/create_db_catalog.sql
I use liquibase to create a table. To work with the JPA database.
spring:
jpa.properties.hibernate.jdbc.lob.non_contextual_creation: true
jpa.properties.hibernate.dialect: org.hibernate.dialect.PostgreSQLDialect
jpa:
show-sql: true
hibernate:
ddl-auto: none
datasource:
initialization-mode: always
driver-class-name: org.postgresql.Driver
jdbc-url: jdbc:postgresql://postgres-content:5432/catalog_content?currentSchema=catalog&stringtype=unspecified
username: content
password: *****
liquibase:
enabled: true
change-log: classpath:db/changelog/db.changelog.xml
Everything works fine. I launch it, I check what I wrote for a day or two. But a few days pass, I connect to the server to download a new version. And my application is constantly overloaded.
Just restarting containers doesn't help.
I'm deleting the directory from the database on the server. I overload and everything works again.
The first time I thought it was an accident. But this happened the second time.
Tell me where and how to find a solution to this problem?
Where to look?
Here's what he writes in the logs:
19-01-2022 07:41:33.921 [main] INFO ru.home.marketplace.contentservice.ContentServiceApplication.logStarting - Starting ContentServiceApplication v1.0-SNAPSHOT using Java 14.0.2 on c8abc4b4ef14 with PID 1 (/content.jar started by root in /)
content-v01 | 19-01-2022 07:41:33.926 [main] INFO ru.home.marketplace.contentservice.ContentServiceApplication.logStartupProfileInfo - No active profile set, falling back to default profiles: default
content-v01 | 19-01-2022 07:41:35.696 [main] INFO org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn - Bootstrapping Spring Data JPA repositories in DEFAULT mode.
content-v01 | 19-01-2022 07:41:35.872 [main] INFO org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn - Finished Spring Data repository scanning in 156 ms. Found 7 JPA repository interfaces.
content-v01 | 19-01-2022 07:41:36.710 [main] INFO org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize - Tomcat initialized with port(s): 9005 (http)
content-v01 | 19-01-2022 07:41:36.730 [main] INFO org.apache.catalina.core.StandardService.log - Starting service [Tomcat]
content-v01 | 19-01-2022 07:41:36.730 [main] INFO org.apache.catalina.core.StandardEngine.log - Starting Servlet engine: [Apache Tomcat/9.0.54]
content-v01 | 19-01-2022 07:41:36.820 [main] INFO org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/content].log - Initializing Spring embedded WebApplicationContext
content-v01 | 19-01-2022 07:41:36.820 [main] INFO org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.prepareWebApplicationContext - Root WebApplicationContext: initialization completed in 2785 ms
content-v01 | 19-01-2022 07:41:37.014 [main] INFO com.zaxxer.hikari.HikariDataSource.getConnection - HikariPool-1 - Starting...
content-v01 | 19-01-2022 07:41:38.138 [main] ERROR com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException - HikariPool-1 - Exception during pool initialization.
content-v01 | org.postgresql.util.PSQLException: The connection attempt failed.
content-v01 | at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:315)
content-v01 | at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
content-v01 | at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:223)
content-v01 | at org.postgresql.Driver.makeConnection(Driver.java:465)
content-v01 | at org.postgresql.Driver.connect(Driver.java:264)
content-v01 | at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
content-v01 | at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:358)
content-v01 | at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
content-v01 | at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:477)
content-v01 | at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:560)
content-v01 | at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
content-v01 | at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
content-v01 | at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:313)
content-v01 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
content-v01 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
content-v01 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
content-v01 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
content-v01 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
content-v01 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
content-v01 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
content-v01 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
content-v01 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
content-v01 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
content-v01 | at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154)
content-v01 | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908)
content-v01 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
content-v01 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
content-v01 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:771)
content-v01 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:763)
content-v01 | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:438)
content-v01 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:339)
content-v01 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329)
content-v01 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1318)
content-v01 | at ru.home.marketplace.contentservice.ContentServiceApplication.main(ContentServiceApplication.java:11)
content-v01 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
content-v01 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
content-v01 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
content-v01 | at java.base/java.lang.reflect.Method.invoke(Method.java:564)
content-v01 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
content-v01 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
content-v01 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
content-v01 | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
content-v01 | Caused by: java.net.UnknownHostException: postgres-content
content-v01 | at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:567)
content-v01 | at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:333)
content-v01 | at java.base/java.net.Socket.connect(Socket.java:648)
content-v01 | at org.postgresql.core.PGStream.createSocket(PGStream.java:231)
content-v01 | at org.postgresql.core.PGStream.<init>(PGStream.java:95)
content-v01 | at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:98)
content-v01 | at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:213)
content-v01 | ... 41 common frames omitted
content-v01 | 19-01-2022 07:41:38.140 [main] WARN org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext.refresh - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: The connection attempt failed.
content-v01 | 19-01-2022 07:41:38.146 [main] INFO org.apache.catalina.core.StandardService.log - Stopping service [Tomcat]
content-v01 | 19-01-2022 07:41:38.162 [main] INFO org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener.logMessage -
content-v01 |
content-v01 | Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
content-v01 | 19-01-2022 07:41:38.184 [main] ERROR org.springframework.boot.SpringApplication.reportFailure - Application run failed
content-v01 | org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: The connection attempt failed.
content-v01 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804)
content-v01 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
content-v01 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
content-v01 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
content-v01 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
content-v01 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
content-v01 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
content-v01 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
content-v01 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
content-v01 | at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154)
content-v01 | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908)
content-v01 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
content-v01 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
content-v01 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:771)
content-v01 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:763)
content-v01 | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:438)
content-v01 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:339)
content-v01 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329)
content-v01 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1318)
content-v01 | at ru.home.marketplace.contentservice.ContentServiceApplication.main(ContentServiceApplication.java:11)
content-v01 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
content-v01 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
content-v01 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
content-v01 | at java.base/java.lang.reflect.Method.invoke(Method.java:564)
content-v01 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
content-v01 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
content-v01 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
content-v01 | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
content-v01 | Caused by: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: The connection attempt failed.
content-v01 | at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:318)
content-v01 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
content-v01 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
content-v01 | ... 27 common frames omitted
content-v01 | Caused by: org.postgresql.util.PSQLException: The connection attempt failed.
content-v01 | at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:315)
content-v01 | at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
content-v01 | at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:223)
content-v01 | at org.postgresql.Driver.makeConnection(Driver.java:465)
content-v01 | at org.postgresql.Driver.connect(Driver.java:264)
content-v01 | at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
content-v01 | at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:358)
content-v01 | at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
content-v01 | at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:477)
content-v01 | at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:560)
content-v01 | at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
content-v01 | at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
content-v01 | at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:313)
content-v01 | ... 29 common frames omitted
content-v01 | Caused by: java.net.UnknownHostException: postgres-content
content-v01 | at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:567)
content-v01 | at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:333)
content-v01 | at java.base/java.net.Socket.connect(Socket.java:648)
content-v01 | at org.postgresql.core.PGStream.createSocket(PGStream.java:231)
content-v01 | at org.postgresql.core.PGStream.<init>(PGStream.java:95)
content-v01 | at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:98)
content-v01 | at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:213)
content-v01 | ... 41 common frames omitted
content-v01 exited with code 1
The database container is unavailable. But why did this happen? And where to look for the error?
Here are the logs of the container with the database after restarting the container. I didn't think to look before restarting.
2022-01-19 07:39:17.471 UTC [1] LOG: starting PostgreSQL 14.1 (Debian 14.1-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2022-01-19 07:39:17.473 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2022-01-19 07:39:17.473 UTC [1] LOG: listening on IPv6 address "::", port 5432
2022-01-19 07:39:17.600 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-01-19 07:39:17.681 UTC [64] LOG: database system was shut down at 2022-01-19 07:39:17 UTC
2022-01-19 07:39:17.721 UTC [1] LOG: database system is ready to accept connections
2022-01-19 07:42:00.441 UTC [1] LOG: received fast shutdown request
2022-01-19 07:42:00.446 UTC [1] LOG: aborting any active transactions
2022-01-19 07:42:00.450 UTC [1] LOG: background worker "logical replication launcher" (PID 70) exited with exit code 1
2022-01-19 07:42:00.454 UTC [65] LOG: shutting down
2022-01-19 07:42:00.546 UTC [1] LOG: database system is shut down

Have you tried running it using the same network?
Add your network to your services named postgres-content and spring.
networks:
- app-network
Finally, create your network definition at the bottom of your docker-compose.yml file.
networks:
app-network:
name: app-network

Related

No ServletContext set. Problem with connection to DB in another container

I have Kotlin pet-project with docker-compose file:
version: '3.1'
services:
app:
build:
context: .
dockerfile: Dockerfile
command: java -jar ./testapp.jar
ports:
- "8080:8080"
depends_on:
- postgres
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://172.25.1.3:5432/kotlin-app
- SPRING_DATASOURCE_USERNAME=postgres
- SPRING_DATASOURCE_PASSWORD=Tolstochok3000
networks:
app-network:
ipv4_address: 172.25.1.2
postgres:
build:
context: docker/db
dockerfile: Dockerfile
command: postgres
environment:
POSTGRES_DB: "kotlin-app"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "Tolstochok3000"
ports:
- "5432:5432"
networks:
app-network:
ipv4_address: 172.25.1.3
restart: always
networks:
app-network:
ipam:
config:
- subnet: 172.25.1.0/16
I tried docker-compose up, postgres started without problem, but app throw exception: Factory method 'resourceHandlerMapping' threw exception;
nested exception is java.lang.IllegalStateException: No ServletContext set
When I started application on localhost (without docker), application work correctly with db in docker.
Application dockerfile:
FROM gradle:jdk17 as builder
WORKDIR /test-kotlin-app
COPY src ./src
COPY build.gradle.kts ./build.gradle.kts
RUN gradle clean build
FROM openjdk:17-alpine as backend
WORKDIR /root
COPY --from=builder /test-kotlin-app/build/libs/* ./app
ENTRYPOINT ["java", "-jar", "/root/app"]
Application propeties:
#DATABSE SETTINGS
datasource:
driver-class-name: org.postgresql.Driver
url: ${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/kotlin-app}
username: ${SPRING_DATASOURCE_USERNAME:postgres}
password: ${SPRING_DATASOURCE_PASSWORD:Tolstochok3000}
#JPA SETTINGS
jpa:
show-sql: 'true'
hibernate:
ddl-auto: none
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
I tried change docker-compose file application.yml (remove variables) and try remove network, but it didn't help
Error: java.lang.IllegalStateException: No ServletContext set
stacktrace:
test_kotlin_app-app-1 | 08:01:35.023 [main] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Before shutdown stats (total=10, active=0, idle=10, waiting=0)
test_kotlin_app-app-1 | 08:01:35.029 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.postgresql.jdbc.PgConnection#2db15f70: (connection evicted)
test_kotlin_app-app-1 | 08:01:35.030 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.postgresql.jdbc.PgConnection#6d2041d5: (connection evicted)
test_kotlin_app-app-1 | 08:01:35.030 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.postgresql.jdbc.PgConnection#22daa83a: (connection evicted)
test_kotlin_app-app-1 | 08:01:35.030 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.postgresql.jdbc.PgConnection#3599b284: (connection evicted)
test_kotlin_app-app-1 | 08:01:35.030 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.postgresql.jdbc.PgConnection#42f55775: (connection evicted)
test_kotlin_app-app-1 | 08:01:35.030 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.postgresql.jdbc.PgConnection#54a28df5: (connection evicted)
test_kotlin_app-app-1 | 08:01:35.030 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.postgresql.jdbc.PgConnection#5668d8b3: (connection evicted)
test_kotlin_app-app-1 | 08:01:35.030 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.postgresql.jdbc.PgConnection#2e9d5d68: (connection evicted)
test_kotlin_app-app-1 | 08:01:35.031 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.postgresql.jdbc.PgConnection#46bbe931: (connection evicted)
test_kotlin_app-app-1 | 08:01:35.031 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.postgresql.jdbc.PgConnection#6b60936: (connection evicted)
test_kotlin_app-app-1 | 08:01:35.032 [main] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - After shutdown stats (total=0, active=0, idle=0, waiting=0)
test_kotlin_app-app-1 | 08:01:35.032 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed.
test_kotlin_app-app-1 | 08:01:35.035 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
test_kotlin_app-app-1 | org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'resourceHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/W
ebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.se
rvlet.HandlerMapping]: Factory method 'resourceHandlerMapping' threw exception; nested exception is java.lang.IllegalStateException: No ServletContext set
test_kotlin_app-app-1 | at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
test_kotlin_app-app-1 | at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
test_kotlin_app-app-1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
test_kotlin_app-app-1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
test_kotlin_app-app-1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
test_kotlin_app-app-1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
test_kotlin_app-app-1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
test_kotlin_app-app-1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
test_kotlin_app-app-1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
test_kotlin_app-app-1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
test_kotlin_app-app-1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
test_kotlin_app-app-1 | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
test_kotlin_app-app-1 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
test_kotlin_app-app-1 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
test_kotlin_app-app-1 | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
test_kotlin_app-app-1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
test_kotlin_app-app-1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
test_kotlin_app-app-1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
test_kotlin_app-app-1 | at ru.rsu.app.KotlinAppApplicationKt.main(KotlinAppApplication.kt:13)
test_kotlin_app-app-1 | Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'resourceHandlerMapping' threw exception; ne
sted exception is java.lang.IllegalStateException: No ServletContext set
test_kotlin_app-app-1 | at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
test_kotlin_app-app-1 | at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
test_kotlin_app-app-1 | ... 18 common frames omitted
test_kotlin_app-app-1 | Caused by: java.lang.IllegalStateException: No ServletContext set
test_kotlin_app-app-1 | at org.springframework.util.Assert.state(Assert.java:76)
test_kotlin_app-app-1 | at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.resourceHandlerMapping(WebMvcConfigurationSupport.java:591)
test_kotlin_app-app-1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
test_kotlin_app-app-1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
test_kotlin_app-app-1 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
test_kotlin_app-app-1 | at java.base/java.lang.reflect.Method.invoke(Method.java:568)
test_kotlin_app-app-1 | at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
test_kotlin_app-app-1 | ... 19 common frames omitted
I resolve problem, when fixed build section in build.gradle.kts file. Remove block tasks.withType and add build section with default spring boot builder:
tasks.named<org.springframework.boot.gradle.tasks.bundling.BootJar>("bootJar") {
mainClass.set("con.example.app.KotlinAppApplicationKt")
archiveBaseName.set("testapp")
archiveFileName.set("testapp.jar") }
Perhaps your DB container is not yet ready when the app is initialized. You may want to implement some waiting mechanism like this or like some of the solutions here.

Spring Boot with ElasticSearch in Groovy: WebClient not present Exception

I am running a small demo spring-boot application where I want to connect my url routes with elasticsearch queries. The app starts up just fine with those gradle dependencies:
implementation('org.springframework.data:spring-data-elasticsearch')
implementation('org.elasticsearch:elasticsearch')
implementation('org.elasticsearch.client:elasticsearch-rest-high-level-client')
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('org.codehaus.groovy:groovy')
As soon as I add the class ElasticsearchClientConfig (not yet used by me, just loaded):
package me.spring.GroovyDemo.store
import me.spring.GroovyDemo.AppConstants
import org.elasticsearch.client.RestHighLevelClient
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.data.elasticsearch.client.ClientConfiguration
import org.springframework.data.elasticsearch.client.RestClients
import org.springframework.data.elasticsearch.core.ElasticsearchOperations
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories
#Configuration
#EnableElasticsearchRepositories(basePackages = "me.spring.GroovyDemo")
#ComponentScan(basePackages = ["me.spring.GroovyDemo"])
class ElasticsearchClientConfig {
#Bean
RestHighLevelClient client() {
ClientConfiguration clientConfiguration
= ClientConfiguration.builder()
.connectedTo(AppConstants.ELASTIC_SERVER)
.build()
return RestClients.create(clientConfiguration).rest()
}
#Bean
ElasticsearchOperations elasticsearchTemplate() {
return new ElasticsearchRestTemplate(client())
}
}
The app fails on startup.
I found many similar issues. But none of them seems to fail with missing Webclient. I don't really get that I would need a WebClient in the first place.
The exception is as follows:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.0)
2021-05-27 12:02:32.598 INFO 4462 --- [ main] m.s.GroovyDemo.GroovyDemoApplication : Starting GroovyDemoApplication using Java 1.8.0_292 on vagrant-VirtualBox with PID 4462 (/home/vagrant/GroovyOpenApi/out/production/classes started by vagrant in /home/vagrant/GroovyOpenApi)
2021-05-27 12:02:32.600 INFO 4462 --- [ main] m.s.GroovyDemo.GroovyDemoApplication : No active profile set, falling back to default profiles: default
2021-05-27 12:02:32.890 WARN 4462 --- [kground-preinit] o.s.h.c.j.Jackson2ObjectMapperBuilder : For Jackson Kotlin classes support please add "com.fasterxml.jackson.module:jackson-module-kotlin" to the classpath
2021-05-27 12:02:33.230 INFO 4462 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Elasticsearch repositories in DEFAULT mode.
2021-05-27 12:02:33.240 INFO 4462 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 6 ms. Found 0 Elasticsearch repository interfaces.
2021-05-27 12:02:33.402 INFO 4462 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Elasticsearch repositories in DEFAULT mode.
2021-05-27 12:02:33.404 INFO 4462 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 1 ms. Found 0 Elasticsearch repository interfaces.
2021-05-27 12:02:33.407 INFO 4462 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Reactive Elasticsearch repositories in DEFAULT mode.
2021-05-27 12:02:33.409 INFO 4462 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 1 ms. Found 0 Reactive Elasticsearch repository interfaces.
2021-05-27 12:02:33.799 INFO 4462 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-05-27 12:02:33.807 INFO 4462 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-05-27 12:02:33.807 INFO 4462 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.46]
2021-05-27 12:02:33.861 INFO 4462 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-05-27 12:02:33.861 INFO 4462 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1065 ms
2021-05-27 12:02:34.035 WARN 4462 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'client' defined in class path resource [me/spring/GroovyDemo/store/ElasticsearchClientConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.RestHighLevelClient]: Factory method 'client' threw exception; nested exception is java.lang.TypeNotPresentException: Type org.springframework.web.reactive.function.client.WebClient not present
2021-05-27 12:02:34.038 INFO 4462 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-05-27 12:02:34.054 INFO 4462 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-05-27 12:02:34.078 ERROR 4462 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'client' defined in class path resource [me/spring/GroovyDemo/store/ElasticsearchClientConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.RestHighLevelClient]: Factory method 'client' threw exception; nested exception is java.lang.TypeNotPresentException: Type org.springframework.web.reactive.function.client.WebClient not present
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1334) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.7.jar:5.3.7]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.7.jar:5.3.7]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:438) [spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:337) [spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336) [spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325) [spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.SpringApplication$run.call(Unknown Source) [spring-boot-2.5.0.jar:2.5.0]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) [groovy-3.0.8.jar:3.0.8]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) [groovy-3.0.8.jar:3.0.8]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148) [groovy-3.0.8.jar:3.0.8]
at me.spring.GroovyDemo.GroovyDemoApplication.main(GroovyDemoApplication.groovy:10) [classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.RestHighLevelClient]: Factory method 'client' threw exception; nested exception is java.lang.TypeNotPresentException: Type org.springframework.web.reactive.function.client.WebClient not present
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.7.jar:5.3.7]
... 23 common frames omitted
Caused by: java.lang.TypeNotPresentException: Type org.springframework.web.reactive.function.client.WebClient not present
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117) ~[na:1.8.0_292]
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125) ~[na:1.8.0_292]
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) ~[na:1.8.0_292]
at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68) ~[na:1.8.0_292]
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138) ~[na:1.8.0_292]
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) ~[na:1.8.0_292]
at sun.reflect.generics.repository.MethodRepository.getReturnType(MethodRepository.java:68) ~[na:1.8.0_292]
at java.lang.reflect.Method.getGenericReturnType(Method.java:255) ~[na:1.8.0_292]
at java.beans.FeatureDescriptor.getReturnType(FeatureDescriptor.java:370) ~[na:1.8.0_292]
at java.beans.Introspector.getTargetEventInfo(Introspector.java:1052) ~[na:1.8.0_292]
at java.beans.Introspector.getBeanInfo(Introspector.java:427) ~[na:1.8.0_292]
at java.beans.Introspector.getBeanInfo(Introspector.java:173) ~[na:1.8.0_292]
at groovy.lang.MetaClassImpl.lambda$addProperties$4(MetaClassImpl.java:3460) ~[groovy-3.0.8.jar:3.0.8]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_292]
at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3460) ~[groovy-3.0.8.jar:3.0.8]
at groovy.lang.MetaClassImpl.reinitialize(MetaClassImpl.java:3442) ~[groovy-3.0.8.jar:3.0.8]
at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3435) ~[groovy-3.0.8.jar:3.0.8]
at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:273) ~[groovy-3.0.8.jar:3.0.8]
at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:315) ~[groovy-3.0.8.jar:3.0.8]
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:258) ~[groovy-3.0.8.jar:3.0.8]
at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:987) ~[groovy-3.0.8.jar:3.0.8]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:71) [groovy-3.0.8.jar:3.0.8]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:156) [groovy-3.0.8.jar:3.0.8]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) [groovy-3.0.8.jar:3.0.8]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) [groovy-3.0.8.jar:3.0.8]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:130) [groovy-3.0.8.jar:3.0.8]
at me.spring.GroovyDemo.store.ElasticsearchClientConfig.client(ElasticsearchClientConfig.groovy:21) ~[classes/:na]
at me.spring.GroovyDemo.store.ElasticsearchClientConfig$$EnhancerBySpringCGLIB$$a214165c.CGLIB$client$0(<generated>) ~[classes/:na]
at me.spring.GroovyDemo.store.ElasticsearchClientConfig$$EnhancerBySpringCGLIB$$a214165c$$FastClassBySpringCGLIB$$c29866d5.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.3.7.jar:5.3.7]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.3.7.jar:5.3.7]
at me.spring.GroovyDemo.store.ElasticsearchClientConfig$$EnhancerBySpringCGLIB$$a214165c.client(<generated>) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_292]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_292]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_292]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_292]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.7.jar:5.3.7]
... 24 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.web.reactive.function.client.WebClient
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_292]
at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_292]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) ~[na:1.8.0_292]
at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_292]
at java.lang.Class.forName0(Native Method) ~[na:1.8.0_292]
at java.lang.Class.forName(Class.java:348) ~[na:1.8.0_292]
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114) ~[na:1.8.0_292]
... 60 common frames omitted
Process finished with exit code 1
Somehow I am not able to create the ES client bean.
My App is in package me.spring.GroovyDemo, everything else is below.
I tried adding some dependencies, like webflux to get WebClient, but did not really help.
What is the reason for the failing startup?
I got your example running by adding
implementation('org.springframework:spring-webflux')
Where does this reference to the WebClient class come from? Spring Data Elasticsearch is built with an optional dependency to org.springframework:spring-webflux because it contains code for both the imperative and the reactive setup. Optional because we need it to build the library, but you do not need it when running - in imperative mode.
Now the ClientConfiguration class and its builder have a method withWebClientConfigurer(Function<WebClient, WebClient> webClientConfigurer). This function is compiled into the library.
When running an imperative, non-reactive application which does not have webflux in it's classpath in Java or Kotlin everything is fine - the application itself was never compiled to use this function and so it is not needed and the transitive optional dependency is never resolved. It does not matter if these optional dependencies are in the loaded class as long as they are not used - otherwise the compiler would have complained.
In Groovy this seems to be different. Here there is some Java-bean inspection running on the ClientConfiguration class which finds the afore mentioned method but cannot find the WebClient class, because that's not on the classpath.
So by adding the dependency to the classpath this error goes away by the cost of having a library with reactive code in the classpath - now some Spring Boot austoconfiguration could be tempted to pick something up from there.
I don't know what would be a better solution, or if groovy can handle optional dependencies better, I'm not using groovy. Someone with more insights might have a better answer.
From the stacktrace follows that you should add a missing dependency to spring-web-reactive to your Gradle config:
dependencies {
//...
implementation 'org.springframework:spring-web-reactive:5.0.0.M4'
}

docker cassandra and springboot microservices not connecting cassandra host

I am using spring boot cassandra microservices,
My docker file is ,
FROM openjdk:11-jdk-slim
VOLUME /tmp
ARG JAR_FILE=build/libs/*.war
COPY ${JAR_FILE} app.war
EXPOSE 8081
ENTRYPOINT ["java","-jar","/app.war"]
my docker compose is
version: "3"
services:
cassandra_node_1:
image: cassandra:3.11.5
container_name: cassandra_node_1
ports:
- 9042:9042
hostname: cassandra_node_1
mem_limit: 2g
healthcheck:
test: ["CMD", "cqlsh", "-e", "describe keyspaces" ]
interval: 5s
timeout: 5s
retries: 60
environment:
- CASSANDRA_SEEDS=cassandra_node_1
- CASSANDRA_DC=datacenter1
milk-vendor-services:
container_name: milk_vendor_1
build:
context: .
restart: on-failure
ports:
- 8081:8081
environment:
- spring.data.cassandra.contact-points=cassandra_node_1
- spring.data.cassandra.port=9042
- spring.data.cassandra.keyspace-name=milk_vendor
- spring.data.cassandra.local-datacenter=datacenter1
- spring.data.cassandra.schema-action=CREATE_IF_NOT_EXISTS
depends_on:
- cassandra_node_1
while I running the above using "docker compose up". I am getting below error, where as working fine without docker.
milk_vendor_1 | 2021-05-16 14:43:24.919 WARN 1 --- [ s0-admin-1] c.d.o.d.i.c.control.ControlConnection : [s0] Error connecting to Node(endPoint=localhost:9042, hostId=null, hashCode=5019c44e), trying next node (ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (io.netty.channel.StacklessClosedChannelException))
milk_vendor_1 | 2021-05-16 14:43:24.954 WARN 1 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'milkVendorResource': Unsatisfied dependency expressed through field 'service'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'milkVendorServiceImpl': Unsatisfied dependency expressed through field 'homeRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IHomeRepository' defined in com.viji.kala.vendor.dao.IHomeRepository defined in #EnableReactiveCassandraRepositories declared on CassandraReactiveRepositoriesRegistrar.EnableReactiveCassandraRepositoriesConfiguration: Cannot resolve reference to bean 'reactiveCassandraTemplate' while setting bean property 'reactiveCassandraOperations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reactiveCassandraTemplate' defined in class path resource [com/viji/kala/vendor/config/CassandraConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.cassandra.core.ReactiveCassandraTemplate]: Factory method 'reactiveCassandraTemplate' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reactiveCassandraSessionFactory' defined in class path resource [com/viji/kala/vendor/config/CassandraConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.cassandra.ReactiveSessionFactory]: Factory method 'reactiveCassandraSessionFactory' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reactiveCassandraSession' defined in class path resource [com/viji/kala/vendor/config/CassandraConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.cassandra.ReactiveSession]: Factory method 'reactiveCassandraSession' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraSession' defined in class path resource [com/viji/kala/vendor/config/CassandraConfig.class]: Invocation of init method failed; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=localhost:9042, hostId=null, hashCode=5019c44e): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (io.netty.channel.StacklessClosedChannelException)]
milk_vendor_1 | 2021-05-16 14:43:24.968 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
milk_vendor_1 | 2021-05-16 14:43:25.174 INFO 1 --- [ main] ConditionEvaluationReportLoggingListener :
milk_vendor_1 |
milk_vendor_1 | Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
milk_vendor_1 | 2021-05-16 14:43:25.520 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed
milk_vendor_1 |
instantiate [org.springframework.data.cassandra.ReactiveSession]: Factory method 'reactiveCassandraSession' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraSession' defined in class path resource [com/viji/kala/vendor/config/CassandraConfig.class]: Invocation of init method failed; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=localhost:9042, hostId=null, hashCode=5019c44e): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (io.netty.channel.StacklessClosedChannelException)]
milk_vendor_1 | at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | ... 114 common frames omitted
milk_vendor_1 | Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraSession' defined in class path resource [com/viji/kala/vendor/config/CassandraConfig.class]: Invocation of init method failed; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=localhost:9042, hostId=null, hashCode=5019c44e): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (io.netty.channel.StacklessClosedChannelException)]
milk_vendor_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:609) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1235) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:494) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:349) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:342) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | at org.springframework.data.cassandra.config.AbstractSessionConfiguration.requireBeanOfType(AbstractSessionConfiguration.java:100) ~[spring-data-cassandra-3.1.1.jar!/:3.1.1]
milk_vendor_1 | at org.springframework.data.cassandra.config.AbstractSessionConfiguration.getRequiredSession(AbstractSessionConfiguration.java:200) ~[spring-data-cassandra-3.1.1.jar!/:3.1.1]
milk_vendor_1 | at org.springframework.data.cassandra.config.AbstractReactiveCassandraConfiguration.reactiveCassandraSession(AbstractReactiveCassandraConfiguration.java:53) ~[spring-data-cassandra-3.1.1.jar!/:3.1.1]
milk_vendor_1 | at com.viji.kala.vendor.config.CassandraConfig$$EnhancerBySpringCGLIB$$73567517.CGLIB$reactiveCassandraSession$5(<generated>) ~[classes!/:na]
milk_vendor_1 | at com.viji.kala.vendor.config.CassandraConfig$$EnhancerBySpringCGLIB$$73567517$$FastClassBySpringCGLIB$$774c088a.invoke(<generated>) ~[classes!/:na]
milk_vendor_1 | at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.3.1.jar!/:5.3.1]
milk_vendor_1 | at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.3.1.jar!/:5.3.1]
milk_vendor_1 | at com.viji.kala.vendor.config.CassandraConfig$$EnhancerBySpringCGLIB$$73567517.reactiveCassandraSession(<generated>) ~[classes!/:na]
milk_vendor_1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
milk_vendor_1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
milk_vendor_1 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
milk_vendor_1 | at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
milk_vendor_1 | at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | ... 115 common frames omitted
milk_vendor_1 | Caused by: com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=localhost:9042, hostId=null, hashCode=5019c44e): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (io.netty.channel.StacklessClosedChannelException)]
milk_vendor_1 | at com.datastax.oss.driver.api.core.AllNodesFailedException.copy(AllNodesFailedException.java:141) ~[java-driver-core-4.9.0.jar!/:na]
milk_vendor_1 | at com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures.getUninterruptibly(CompletableFutures.java:149) ~[java-driver-core-4.9.0.jar!/:na]
milk_vendor_1 | at com.datastax.oss.driver.api.core.session.SessionBuilder.build(SessionBuilder.java:697) ~[java-driver-core-4.9.0.jar!/:na]
milk_vendor_1 | at org.springframework.data.cassandra.config.CqlSessionFactoryBean.buildSystemSession(CqlSessionFactoryBean.java:498) ~[spring-data-cassandra-3.1.1.jar!/:3.1.1]
milk_vendor_1 | at org.springframework.data.cassandra.config.CqlSessionFactoryBean.afterPropertiesSet(CqlSessionFactoryBean.java:451) ~[spring-data-cassandra-3.1.1.jar!/:3.1.1]
milk_vendor_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1847) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1784) ~[spring-beans-5.3.1.jar!/:5.3.1]
milk_vendor_1 | ... 138 common frames omitted
milk_vendor_1 | Suppressed: com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (io.netty.channel.StacklessClosedChannelException)
milk_vendor_1 | at com.datastax.oss.driver.internal.core.channel.ProtocolInitHandler$InitRequest.fail(ProtocolInitHandler.java:354) ~[java-driver-core-4.9.0.jar!/:na]
milk_vendor_1 | at com.datastax.oss.driver.internal.core.channel.ChannelHandlerRequest.writeListener(ChannelHandlerRequest.java:87) ~[java-driver-core-4.9.0.jar!/:na]
milk_vendor_1 | at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:552) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:184) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:95) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:30) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at com.datastax.oss.driver.internal.core.channel.ChannelHandlerRequest.send(ChannelHandlerRequest.java:76) ~[java-driver-core-4.9.0.jar!/:na]
milk_vendor_1 | at com.datastax.oss.driver.internal.core.channel.ProtocolInitHandler$InitRequest.send(ProtocolInitHandler.java:193) ~[java-driver-core-4.9.0.jar!/:na]
milk_vendor_1 | at com.datastax.oss.driver.internal.core.channel.ProtocolInitHandler.onRealConnect(ProtocolInitHandler.java:124) ~[java-driver-core-4.9.0.jar!/:na]
milk_vendor_1 | at com.datastax.oss.driver.internal.core.channel.ConnectInitHandler.lambda$connect$0(ConnectInitHandler.java:57) ~[java-driver-core-4.9.0.jar!/:na]
milk_vendor_1 | at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:571) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:550) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:616) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.util.concurrent.DefaultPromise.setFailure0(DefaultPromise.java:609) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:117) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:321) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:337) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:707) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.54.Final.jar!/:4.1.54.Final]
milk_vendor_1 | at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]
milk_vendor_1 | Suppressed: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/127.0.0.1:9042
milk_vendor_1 | Caused by: java.net.ConnectException: Connection refused
milk_vendor_1 | at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
milk_vendor_1 | at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:777)
milk_vendor_1 | at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:330)
milk_vendor_1 | at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
milk_vendor_1 | at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:707)
milk_vendor_1 | at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
milk_vendor_1 | at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
milk_vendor_1 | at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
milk_vendor_1 | at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
milk_vendor_1 | at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
milk_vendor_1 | at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
milk_vendor_1 | at java.base/java.lang.Thread.run(Thread.java:829)
milk_vendor_1 | Caused by: io.netty.channel.StacklessClosedChannelException: null
milk_vendor_1 | at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0()(Unknown Source)
So a few things caught my eye here:
FROM openjdk:11-jdk-slim
...
image: cassandra:3.11.5
Cassandra version <= 3 will only run on Java 8 (or lower). It will fail to start on anything else.
Error connecting to Node(endPoint=localhost:9042,
- spring.data.cassandra.contact-points=cassandra_node_1
I'm curious as to what cassandra_node_1 resolves to, as I'm pretty sure it's not localhost. Note, that you can only connect to the endpoints that are being broadcasted by Cassandra. So if your listen_address and rpc_address are both set to localhost in your cassandra.yaml, you'll only ever be able to connect locally and only by the values of localhost or 127.0.0.1. If you need to be able to reach it remotely at cassandra_node_1 then that's what those _address properties should be set to.

Spring boot with embeded tomcat on AWS is start to fail

I was able to start it properly with same configuration and port, however suddenly its unable to start with below log. As per the log, its a Caused by: java.net.SocketException: Permission denied
However I am surprised that nothing has changed then how suddenly I am getting permission denied, not getting any further clue, can someone suggest please
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.7.RELEASE)
2021-02-03 10:09:32.282 INFO 26951 --- [ main] c.p.w.e.WebhookEndpointApplication : Starting WebhookEndpointApplication v1.0.0 on ip-172-31-2
6-225.eu-central-1.compute.internal with PID 26951 (/home/ec2-user/webhook-app/webhook-endpoint/target/webhook-endpoint-1.0.0.jar started by ec2-user in /home
/ec2-user/webhook-app/webhook-endpoint)
2021-02-03 10:09:32.286 INFO 26951 --- [ main] c.p.w.e.WebhookEndpointApplication : No active profile set, falling back to default profiles:
default
2021-02-03 10:09:33.424 INFO 26951 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT
mode.
2021-02-03 10:09:33.504 INFO 26951 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 72ms. Found 1
MongoDB repository interfaces.
2021-02-03 10:09:34.267 INFO 26951 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 80 (http)
2021-02-03 10:09:34.283 INFO 26951 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-02-03 10:09:34.284 INFO 26951 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.34]
2021-02-03 10:09:34.412 INFO 26951 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-02-03 10:09:34.412 INFO 26951 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2
017 ms
2021-02-03 10:09:34.756 INFO 26951 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[localhost:27017], m
ode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2021-02-03 10:09:34.981 INFO 26951 --- [localhost:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:1, serverValue
:11}] to localhost:27017
2021-02-03 10:09:34.990 INFO 26951 --- [localhost:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with desc
ription ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 2, 8]}, minWireVersion=0,
maxWireVersion=8, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=6701667}
2021-02-03 10:09:35.550 INFO 26951 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-02-03 10:09:35.793 INFO 26951 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-02-03 10:09:35.802 INFO 26951 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-02-03 10:09:35.808 ERROR 26951 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:212) ~[spring-boot-2.2.7.RELEASE.jar!/:2.2.7.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:297) ~[sprin
g-boot-2.2.7.RELEASE.jar!/:2.2.7.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:163) ~[spring
-boot-2.2.7.RELEASE.jar!/:2.2.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) ~[spring-context-5.2.6.RELEASE.jar!/:5.
2.6.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-
2.2.7.RELEASE.jar!/:2.2.7.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.7.RELEASE.jar!/:2.2.7.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.7.RELEASE.jar!/:2.2.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.7.RELEASE.jar!/:2.2.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.7.RELEASE.jar!/:2.2.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.7.RELEASE.jar!/:2.2.7.RELEASE]
at com.payon.webhook.endpoint.WebhookEndpointApplication.main(WebhookEndpointApplication.java:10) [classes!/:1.0.0]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_252]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_252]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_252]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_252]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [webhook-endpoint-1.0.0.jar:1.0.0]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [webhook-endpoint-1.0.0.jar:1.0.0]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) [webhook-endpoint-1.0.0.jar:1.0.0]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) [webhook-endpoint-1.0.0.jar:1.0.0]
Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:231) ~[tomcat-embed-core-9.0.34.jar!/:9.0.34]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:265) ~[spring-boot-2.2.7.RELEASE.j
ar!/:2.2.7.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:196) ~[spring-boot-2.2.7.RELEASE.jar!/:2.2.7.RELEASE]
... 18 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1066) ~[tomcat-embed-core-9.0.34.jar!/:9.0.34]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.34.jar!/:9.0.34]
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:227) ~[tomcat-embed-core-9.0.34.jar!/:9.0.34]
... 20 common frames omitted
Caused by: java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_252]
at sun.nio.ch.Net.bind(Net.java:433) ~[na:1.8.0_252]
at sun.nio.ch.Net.bind(Net.java:425) ~[na:1.8.0_252]
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:220) ~[na:1.8.0_252]
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:85) ~[na:1.8.0_252]
at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:228) ~[tomcat-embed-core-9.0.34.jar!/:9.0.34]
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:211) ~[tomcat-embed-core-9.0.34.jar!/:9.0.34]
at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1141) ~[tomcat-embed-core-9.0.34.jar!/:9.0.34]
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1227) ~[tomcat-embed-core-9.0.34.jar!/:9.0.34]
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:592) ~[tomcat-embed-core-9.0.34.jar!/:9.0.34]
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1063) ~[tomcat-embed-core-9.0.34.jar!/:9.0.34]
... 22 common frames omitted
You can look at this answer: Spring Boot deploy with Tomcat.
In my case; i included the tomcat dependency in the pom file;and I use 8080 as the server pot; which solves my issue.
In addition, don't forget to check your jre and jdk version.

Application run failed

Please help who know spring boot
"C:\Program Files (x86)\Java\jdk1.8.0_151\bin\java" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=55790 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.3.2\lib\idea_rt.jar=55791:C:\Program Files\JetBrains\IntelliJ IDEA 2017.3.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\charsets.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\deploy.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\ext\access-bridge-32.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\ext\cldrdata.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\ext\dnsns.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\ext\jaccess.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\ext\jfxrt.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\ext\localedata.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\ext\nashorn.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\ext\sunec.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\ext\sunjce_provider.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\ext\sunmscapi.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\ext\sunpkcs11.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\ext\zipfs.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\javaws.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\jce.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\jfr.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\jfxswt.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\jsse.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\management-agent.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\plugin.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\resources.jar;C:\Program Files (x86)\Java\jdk1.8.0_151\jre\lib\rt.jar;D:\cargofin\target\classes;C:\Users\Администратор\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.0.3.RELEASE\spring-boot-starter-web-2.0.3.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\boot\spring-boot-starter\2.0.3.RELEASE\spring-boot-starter-2.0.3.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.0.3.RELEASE\spring-boot-starter-logging-2.0.3.RELEASE.jar;C:\Users\Администратор\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\Администратор\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\Администратор\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.10.0\log4j-to-slf4j-2.10.0.jar;C:\Users\Администратор\.m2\repository\org\apache\logging\log4j\log4j-api\2.10.0\log4j-api-2.10.0.jar;C:\Users\Администратор\.m2\repository\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;C:\Users\Администратор\.m2\repository\org\springframework\spring-core\5.0.7.RELEASE\spring-core-5.0.7.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\spring-jcl\5.0.7.RELEASE\spring-jcl-5.0.7.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\yaml\snakeyaml\1.19\snakeyaml-1.19.jar;C:\Users\Администратор\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.0.3.RELEASE\spring-boot-starter-json-2.0.3.RELEASE.jar;C:\Users\Администратор\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.9.6\jackson-databind-2.9.6.jar;C:\Users\Администратор\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;C:\Users\Администратор\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.6\jackson-datatype-jdk8-2.9.6.jar;C:\Users\Администратор\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.6\jackson-datatype-jsr310-2.9.6.jar;C:\Users\Администратор\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.6\jackson-module-parameter-names-2.9.6.jar;C:\Users\Администратор\.m2\repository\org\hibernate\validator\hibernate-validator\6.0.10.Final\hibernate-validator-6.0.10.Final.jar;C:\Users\Администратор\.m2\repository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;C:\Users\Администратор\.m2\repository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;C:\Users\Администратор\.m2\repository\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;C:\Users\Администратор\.m2\repository\org\springframework\spring-web\5.0.7.RELEASE\spring-web-5.0.7.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\spring-beans\5.0.7.RELEASE\spring-beans-5.0.7.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\spring-webmvc\5.0.7.RELEASE\spring-webmvc-5.0.7.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\spring-aop\5.0.7.RELEASE\spring-aop-5.0.7.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\spring-context\5.0.7.RELEASE\spring-context-5.0.7.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\spring-expression\5.0.7.RELEASE\spring-expression-5.0.7.RELEASE.jar;C:\Users\Администратор\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.9.6\jackson-core-2.9.6.jar;C:\Users\Администратор\.m2\repository\org\springframework\boot\spring-boot-starter-data-jpa\2.0.3.RELEASE\spring-boot-starter-data-jpa-2.0.3.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\boot\spring-boot-starter-aop\2.0.3.RELEASE\spring-boot-starter-aop-2.0.3.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\aspectj\aspectjweaver\1.8.13\aspectjweaver-1.8.13.jar;C:\Users\Администратор\.m2\repository\org\hibernate\hibernate-core\5.2.17.Final\hibernate-core-5.2.17.Final.jar;C:\Users\Администратор\.m2\repository\org\hibernate\javax\persistence\hibernate-jpa-2.1-api\1.0.2.Final\hibernate-jpa-2.1-api-1.0.2.Final.jar;C:\Users\Администратор\.m2\repository\org\javassist\javassist\3.22.0-GA\javassist-3.22.0-GA.jar;C:\Users\Администратор\.m2\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;C:\Users\Администратор\.m2\repository\org\jboss\jandex\2.0.3.Final\jandex-2.0.3.Final.jar;C:\Users\Администратор\.m2\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;C:\Users\Администратор\.m2\repository\org\hibernate\common\hibernate-commons-annotations\5.0.1.Final\hibernate-commons-annotations-5.0.1.Final.jar;C:\Users\Администратор\.m2\repository\javax\transaction\javax.transaction-api\1.2\javax.transaction-api-1.2.jar;C:\Users\Администратор\.m2\repository\org\springframework\data\spring-data-jpa\2.0.8.RELEASE\spring-data-jpa-2.0.8.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\data\spring-data-commons\2.0.8.RELEASE\spring-data-commons-2.0.8.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\spring-orm\5.0.7.RELEASE\spring-orm-5.0.7.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\spring-tx\5.0.7.RELEASE\spring-tx-5.0.7.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\spring-aspects\5.0.7.RELEASE\spring-aspects-5.0.7.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\boot\spring-boot-devtools\2.0.3.RELEASE\spring-boot-devtools-2.0.3.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\boot\spring-boot\2.0.3.RELEASE\spring-boot-2.0.3.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.3.RELEASE\spring-boot-autoconfigure-2.0.3.RELEASE.jar;C:\Users\Администратор\.m2\repository\com\google\code\gson\gson\2.8.5\gson-2.8.5.jar;C:\Users\Администратор\.m2\repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;C:\Users\Администратор\.m2\repository\javax\servlet\jstl\1.2\jstl-1.2.jar;C:\Users\Администратор\.m2\repository\com\zaxxer\HikariCP\2.7.9\HikariCP-2.7.9.jar;C:\Users\Администратор\.m2\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;C:\Users\Администратор\.m2\repository\com\microsoft\sqlserver\mssql-jdbc\6.5.0.jre8-preview\mssql-jdbc-6.5.0.jre8-preview.jar;C:\Users\Администратор\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\2.0.3.RELEASE\spring-boot-starter-jdbc-2.0.3.RELEASE.jar;C:\Users\Администратор\.m2\repository\org\springframework\spring-jdbc\5.0.7.RELEASE\spring-jdbc-5.0.7.RELEASE.jar" myapp.SpringBootApplication
15:22:41.243 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
15:22:41.247 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/, /spring-boot/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter/target/classes/]
15:22:41.248 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/D:/cargofin/target/classes/]
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.3.RELEASE)
2018-08-15 15:22:43.609 INFO 6868 --- [ restartedMain] myapp.SpringBootApplication : Starting SpringBootApplication on ADmin-PC with PID 6868 (D:\cargofin\target\classes started by Администратор in D:\cargofin)
2018-08-15 15:22:43.611 INFO 6868 --- [ restartedMain] myapp.SpringBootApplication : No active profile set, falling back to default profiles: default
2018-08-15 15:22:43.889 INFO 6868 --- [ restartedMain] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#7c07ce: startup date [Wed Aug 15 15:22:43 AZT 2018]; root of context hierarchy
2018-08-15 15:22:45.021 WARN 6868 --- [ restartedMain] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [myapp.SpringBootApplication]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.servlet.support.SpringBootServletInitializer
2018-08-15 15:22:45.130 ERROR 6868 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [myapp.SpringBootApplication]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.servlet.support.SpringBootServletInitializer
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at myapp.SpringBootApplication.main(SpringBootApplication.java:24) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.3.RELEASE.jar:2.0.3.RELEASE]
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.servlet.support.SpringBootServletInitializer
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:169) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.retrieveBeanMethodMetadata(ConfigurationClassParser.java:393) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:318) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:202) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:170) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
... 17 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_151]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_151]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_151]
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:158) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
... 22 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_151]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_151]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_151]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_151]
... 26 common frames omitted
Process finished with exit code 0
**strong text**
Looks like your javax.servlet dependency is missing try to add:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
This worked fine for me after including the main class in a package.
Please look into:
o.s.boot.SpringApplication : Application run failed
for further updates on what all versions I used.

Resources