docker cassandra and springboot microservices not connecting cassandra host - spring

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.

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.

After a few days, the Java application stops working

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

Kubernetes - SpringBoot - Neo4j - error at startup

I have a SpringBoot application that connect to Neo4j at startup using the code below
We deploy a pod for Neo4j and one for this application.
When the service port of Neo4j are UP, our application pod starts, but we get those errors when the pod start too soon.
There is a way to configure Spring to reconnect to Neo4j until it's available ?
#Configuration
#EnableNeo4jRepositories(basePackages = "com.repository")
#EnableTransactionManagement
public class Neo4jConfig {
private final Environment env;
#Autowired
public Neo4jConfig(Environment env) {
this.env = env;
}
#Bean
public SessionFactory sessionFactory() {
return new SessionFactory(configuration(), "com.model");
}
#Bean
public org.neo4j.ogm.config.Configuration configuration() {
return new Builder()
.uri(env.getProperty("db.uri"))
.credentials(env.getProperty("db.username"), env.getProperty("db.password"))
.autoIndex("update")
.build();
}
#Bean
public Neo4jTransactionManager transactionManager() {
return new Neo4jTransactionManager(sessionFactory());
}
}
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.4.RELEASE)
2020-10-15 14:26:32.319 INFO 1 --- [ main] com.comact.App : Starting App v1.0.0-SNAPSHOT on twin-api-service-5b74974d84-pngvs with PID 1 (/app/app.jar started by root in /app)
2020-10-15 14:26:32.323 INFO 1 --- [ main] com.comact.App : The following profiles are active: kubernetes,production
2020-10-15 14:26:33.713 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Neo4j repositories in DEFAULT mode.
2020-10-15 14:26:33.797 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 71ms. Found 2 Neo4j repository interfaces.
2020-10-15 14:26:34.843 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-10-15 14:26:35.255 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-10-15 14:26:35.271 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-10-15 14:26:35.272 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.30]
2020-10-15 14:26:35.363 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-10-15 14:26:35.363 INFO 1 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2952 ms
2020-10-15 14:26:36.310 INFO 1 --- [ main] org.neo4j.ogm.metadata.DomainInfo : Starting Post-processing phase
2020-10-15 14:26:36.310 INFO 1 --- [ main] org.neo4j.ogm.metadata.DomainInfo : Building byLabel lookup maps
2020-10-15 14:26:36.310 INFO 1 --- [ main] org.neo4j.ogm.metadata.DomainInfo : Building interface class map for 19 classes
2020-10-15 14:26:36.333 INFO 1 --- [ main] org.neo4j.ogm.metadata.DomainInfo : Post-processing complete
2020-10-15 14:26:36.526 INFO 1 --- [ main] Driver : Direct driver instance 550572371 created for server address twin-neo4j:7687
2020-10-15 14:26:36.671 ERROR 1 --- [ main] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'neo4jHealthContributor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/neo4j/Neo4jHealthContributorAutoConfiguration.class]: Unsatisfied dependency expressed through method 'neo4jHealthContributor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/comact/twin/config/Neo4jConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is org.neo4j.ogm.exception.ConnectionException: Could not create driver instance
2020-10-15 14:26:36.705 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-10-15 14:26:36.713 WARN 1 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [Neo4jDriverIO-2-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base#11.0.8/sun.nio.ch.EPoll.wait(Native Method)
java.base#11.0.8/sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:120)
java.base#11.0.8/sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:124)
java.base#11.0.8/sun.nio.ch.SelectorImpl.select(SelectorImpl.java:136)
org.neo4j.driver.internal.shaded.io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:824)
org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:457)
org.neo4j.driver.internal.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1044)
org.neo4j.driver.internal.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
org.neo4j.driver.internal.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
java.base#11.0.8/java.lang.Thread.run(Thread.java:834)
2020-10-15 14:26:36.713 WARN 1 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [Neo4jDriverIO-2-2] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base#11.0.8/sun.nio.ch.EPoll.wait(Native Method)
java.base#11.0.8/sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:120)
java.base#11.0.8/sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:124)
java.base#11.0.8/sun.nio.ch.SelectorImpl.select(SelectorImpl.java:136)
org.neo4j.driver.internal.shaded.io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:824)
org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:457)
org.neo4j.driver.internal.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1044)
org.neo4j.driver.internal.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
org.neo4j.driver.internal.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
java.base#11.0.8/java.lang.Thread.run(Thread.java:834)
2020-10-15 14:26:36.716 WARN 1 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2020-10-15 14:26:36.735 INFO 1 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-10-15 14:26:36.744 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:156) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at com.comact.App.main(App.java:9) ~[classes!/:1.0.0-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) ~[app.jar:1.0.0-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[app.jar:1.0.0-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) ~[app.jar:1.0.0-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) ~[app.jar:1.0.0-SNAPSHOT]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:88) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:438) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:191) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:180) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:153) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
... 16 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'neo4jHealthContributor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/neo4j/Neo4jHealthContributorAutoConfiguration.class]: Unsatisfied dependency expressed through method 'neo4jHealthContributor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/comact/twin/config/Neo4jConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is org.neo4j.ogm.exception.ConnectionException: Could not create driver instance
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:211) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:202) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:96) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:85) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:253) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:227) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:53) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5135) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:459) ~[tomcat-embed-core-9.0.30.jar!/:9.0.30]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:107) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
... 21 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'neo4jHealthContributor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/neo4j/Neo4jHealthContributorAutoConfiguration.class]: Unsatisfied dependency expressed through method 'neo4jHealthContributor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/comact/twin/config/Neo4jConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is org.neo4j.ogm.exception.ConnectionException: Could not create driver instance
at
...
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'neo4jHealthContributor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/neo4j/Neo4jHealthContributorAutoConfiguration.class]: Unsatisfied dependency expressed through method 'neo4jHealthContributor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/comact/twin/config/Neo4jConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is org.neo4j.ogm.exception.ConnectionException: Could not create driver instance
....
Caused by: org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: twin-neo4j/10.104.227.154:7687
Caused by: java.net.ConnectException: Connection refused
at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:na]
at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:779) ~[na:na]
...
I opened a issue here to do a follow up : https://github.com/spring-projects/spring-boot/issues/23707#issuecomment-709483144

spring-boot-maven-plugin: start does not recognize that app has already started

I'm trying to use the spring-boot-maven-plugin for integration tests like documented, but I always get 'Spring application did not start before the configured timeout'. However, using 'fork=false' spring server app is saying:
18:30:14.442 [http-nio-8080-exec-1] INFO o.s.web.servlet.DispatcherServlet.initServletBean - Initializing Servlet 'dispatcherServlet'
18:30:14.446 [http-nio-8080-exec-1] INFO o.s.web.servlet.DispatcherServlet.initServletBean - Completed initialization in 4 ms
18:30:21.918 [http-nio-8080-exec-2] WARN o.s.w.s.m.s.DefaultHandlerExceptionResolver.logException - Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported]
18:31:05.899 [http-nio-8080-exec-3] WARN o.s.w.s.m.s.DefaultHandlerExceptionResolver.logException - Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported]
Because of this, I guess that the plugin simply has not found out that the app already has started.
However, it I use 'fork=true' (default), I always get the following error:
16:40:54.546 [restartedMain] ERROR o.s.boot.SpringApplication.reportFailure - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectorServerFactoryBean' defined in class path resource [org/springdoc/demo/app2/config/ConfigureRMI.class]: Invocation of init method failed; nested exception is java.io.IOException: Cannot bind to URL [rmi://localhost:9001/jmxrmi]: javax.naming.CommunicationException [Root exception is java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.io.InvalidClassException: filter status: REJECTED]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1803)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:860)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at org.springdoc.demo.app2.Application.main(Application.java:20)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.io.IOException: Cannot bind to URL [rmi://localhost:9001/jmxrmi]: javax.naming.CommunicationException [Root exception is java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.io.InvalidClassException: filter status: REJECTED]
at java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:854)
at java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:501)
at org.springframework.jmx.support.ConnectorServerFactoryBean.afterPropertiesSet(ConnectorServerFactoryBean.java:193)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1862)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1799)
... 21 common frames omitted
Caused by: javax.naming.CommunicationException: null
at jdk.naming.rmi/com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:162)
at java.naming/com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:230)
at java.naming/javax.naming.InitialContext.bind(InitialContext.java:417)
at java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:713)
at java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:496)
... 24 common frames omitted
Caused by: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.io.InvalidClassException: filter status: REJECTED
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:391)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
at java.rmi/sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:303)
at java.rmi/sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:279)
at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:375)
at java.rmi/sun.rmi.registry.RegistryImpl_Stub.bind(RegistryImpl_Stub.java:73)
at jdk.naming.rmi/com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:156)
... 28 common frames omitted
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.io.InvalidClassException: filter status: REJECTED
at java.rmi/sun.rmi.registry.RegistryImpl_Skel.dispatch(RegistryImpl_Skel.java:91)
at java.rmi/sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:468)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:298)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.io.InvalidClassException: filter status: REJECTED
at java.base/java.io.ObjectInputStream.filterCheck(ObjectInputStream.java:1287)
at java.base/java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1896)
at java.base/java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1772)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2060)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1594)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
at java.rmi/sun.rmi.registry.RegistryImpl_Skel.dispatch(RegistryImpl_Skel.java:88)
... 14 common frames omitted
These are my questions:
How does the plugin try to find out if the application has started?
If 'fork=true'? JMX/RMI? Which port? Which MBean?
If 'fork=false'?
How to avoid the error in case of 'fork=true'?

spring boot application exception

i am trying to run a simple spring boot application but unable to run it . please help . this is my main file , pom.xml and error
Pom.xml
Main Function
stack trace:
2019-01-26 12:43:11.619 INFO 17684 --- [ main] c.w.service.service.ServiceApplication : Starting ServiceApplication on DESKTOP-T03T8BR with PID 17684 (D:\hello\service\target\classes started by Nexus in D:\hello\service)
2019-01-26 12:43:11.624 INFO 17684 --- [ main] c.w.service.service.ServiceApplication : No active profile set, falling back to default profiles: default
2019-01-26 12:43:11.775 INFO 17684 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#2d2e5f00: startup date [Sat Jan 26 12:43:11 PKT 2019]; root of context hierarchy
2019-01-26 12:43:13.912 INFO 17684 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$2e4eba9b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-01-26 12:43:13.942 WARN 17684 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'annotationActionEndpointMapping' defined in class path resource [org/springframework/ws/config/annotation/DelegatingWsConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping]: Factory method 'annotationActionEndpointMapping' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/xml/DocumentBuilderFactoryUtils
2019-01-26 12:43:13.958 INFO 17684 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-01-26 12:43:13.977 ERROR 17684 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'annotationActionEndpointMapping' defined in class path resource [org/springframework/ws/config/annotation/DelegatingWsConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping]: Factory method 'annotationActionEndpointMapping' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/xml/DocumentBuilderFactoryUtils
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:226) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:709) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:534) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at com.web.service.service.ServiceApplication.main(ServiceApplication.java:10) [classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping]: Factory method 'annotationActionEndpointMapping' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/xml/DocumentBuilderFactoryUtils
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
... 18 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/xml/DocumentBuilderFactoryUtils
at org.springframework.ws.soap.addressing.version.AbstractAddressingVersion.<clinit>(AbstractAddressingVersion.java:66) ~[spring-ws-core-3.0.6.RELEASE.jar:na]
at org.springframework.ws.soap.addressing.server.AbstractAddressingEndpointMapping.initDefaultStrategies(AbstractAddressingEndpointMapping.java:107) ~[spring-ws-core-3.0.6.RELEASE.jar:na]
at org.springframework.ws.soap.addressing.server.AbstractAddressingEndpointMapping.<init>(AbstractAddressingEndpointMapping.java:98) ~[spring-ws-core-3.0.6.RELEASE.jar:na]
at org.springframework.ws.soap.addressing.server.AbstractActionEndpointMapping.<init>(AbstractActionEndpointMapping.java:38) ~[spring-ws-core-3.0.6.RELEASE.jar:na]
at org.springframework.ws.soap.addressing.server.AbstractActionMethodEndpointMapping.<init>(AbstractActionMethodEndpointMapping.java:34) ~[spring-ws-core-3.0.6.RELEASE.jar:na]
at org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping.<init>(AnnotationActionEndpointMapping.java:60) ~[spring-ws-core-3.0.6.RELEASE.jar:na]
at org.springframework.ws.config.annotation.WsConfigurationSupport.annotationActionEndpointMapping(WsConfigurationSupport.java:120) ~[spring-ws-core-3.0.6.RELEASE.jar:na]
at org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$2e4eba9b.CGLIB$annotationActionEndpointMapping$4(<generated>) ~[spring-ws-core-3.0.6.RELEASE.jar:na]
at org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$2e4eba9b$$FastClassBySpringCGLIB$$d551914b.invoke(<generated>) ~[spring-ws-core-3.0.6.RELEASE.jar:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$2e4eba9b.annotationActionEndpointMapping(<generated>) ~[spring-ws-core-3.0.6.RELEASE.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_191]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
... 19 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.xml.DocumentBuilderFactoryUtils
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_191]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_191]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_191]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_191]
... 36 common frames omitted
please help.
In build.gradle add dependency
compile"org.springframework.ws:spring-xml:${springWsCoreVersion}"
Do you have something in your application.properies file? Have you tried to remove jpa and h2 dependencies from the pom and start the application? :)
Here is a hint for you. I think you should make some entities and fill them with values.
Check out this link: https://spring.io/guides/gs/accessing-data-jpa/

Resources