Communications link failure , docker-compose - java

i have a problem with docker compose when i try to run docker-compose every time i get the following error i tried many solutions but nothing helps. Please help.
I will add that I created the docker image using Cloud Native Buildpacks. I used the command:
mvn spring-boot: build-image -Dspring-boot.build-image.imageName = jakuczczubak/infrastock
and then uploaded the image to dockerhub
dockerhub: dockerhub
github: github
docker-compose.yml
services:
mysql:
image: mysql:5.7
container_name: test-mysql-docker
environment:
- MYSQL_ROOT_PASSWORD=mysqlpw
- MYSQL_USER=infrastock
- MYSQL_DATABASE=infrastock
- MYSQL_PASSWORD=infrastock123
ports:
- 33067:3306
adminer:
image: adminer
restart: always
ports:
- 8080:8080
depends_on:
- mysql
api:
image: czubakjakub/infrastock:v1.0.0
environment:
- SPRING_DATASOURCE_URL=jdbc:mysql://root:mysqlpw#test-mysql-docker:3306/infrastock?useSSL=false
- SPRING_JPA_HIBERNATE_DDL-AUTO=update
ports:
- 9090:9090
depends_on:
- mysql
application.properties
server.port=9090
spring.datasource.url=jdbc:mysql://root:mysqlpw#host.docker.internal:33067/infrastock
spring.jpa.hibernate.ddl-auto=update
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
error:
- Network docker-compose_default Created 2.6s
- Container test-mysql-docker Created 0.6s
- Container docker-compose-api-1 Created 0.6s
- Container docker-compose-adminer-1 Created 0.5s
Attaching to docker-compose-adminer-1, docker-compose-api-1, test-mysql-docker
test-mysql-docker | 2022-06-22 18:55:25+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.38-1debian10 started.
test-mysql-docker | 2022-06-22 18:55:25+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
test-mysql-docker | 2022-06-22 18:55:25+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.38-1debian10 started.
test-mysql-docker | 2022-06-22 18:55:25+00:00 [Note] [Entrypoint]: Initializing database files
test-mysql-docker | 2022-06-22T18:55:25.410856Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
test-mysql-docker | 2022-06-22T18:55:27.139862Z 0 [Warning] InnoDB: New log files created, LSN=45790
test-mysql-docker | 2022-06-22T18:55:27.489120Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
test-mysql-docker | 2022-06-22T18:55:27.590997Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: e1816692-f25c-11ec-951c-0242ac130002.
test-mysql-docker | 2022-06-22T18:55:27.604367Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
test-mysql-docker | 2022-06-22T18:55:28.037561Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
test-mysql-docker | 2022-06-22T18:55:28.037615Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
test-mysql-docker | 2022-06-22T18:55:28.038212Z 0 [Warning] CA certificate ca.pem is self signed.
test-mysql-docker | 2022-06-22T18:55:28.080678Z 1 [Warning] root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
docker-compose-adminer-1 | [Wed Jun 22 18:55:29 2022] PHP 7.4.30 Development Server (http://[::]:8080) started
docker-compose-api-1 | Setting Active Processor Count to 8
docker-compose-api-1 | Calculating JVM memory based on 7046808K available memory
docker-compose-api-1 | `For more information on this calculation, see https://paketo.io/docs/reference/java-reference/#memory-calculator
docker-compose-api-1 | Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -Xmx6417274K -XX:MaxMetaspaceSize=117533K -XX:ReservedCodeCacheSize=240M -Xss1M (Total Memory: 7046808K, Thread Count: 250, Loaded Class Count: 18337, Headroom: 0%)
docker-compose-api-1 | Enabling Java Native Memory Tracking
docker-compose-api-1 | Adding 127 container CA certificates to JVM truststore
docker-compose-api-1 | Spring Cloud Bindings Enabled
docker-compose-api-1 | Picked up JAVA_TOOL_OPTIONS: -Djava.security.properties=/layers/paketo-buildpacks_bellsoft-liberica/java-security-properties/java-security.properties -XX:+ExitOnOutOfMemoryError -XX:ActiveProcessorCount=8 -XX:MaxDirectMemorySize=10M -Xmx6417274K -XX:MaxMetaspaceSize=117533K -XX:ReservedCodeCacheSize=240M -Xss1M -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+PrintNMTStatistics -Dorg.springframework.cloud.bindings.boot.enable=true
docker-compose-api-1 |
docker-compose-api-1 | . ____ _ __ _ _
docker-compose-api-1 | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
docker-compose-api-1 | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
docker-compose-api-1 | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
docker-compose-api-1 | ' |____| .__|_| |_|_| |_\__, | / / / /
docker-compose-api-1 | =========|_|==============|___/=/_/_/_/
docker-compose-api-1 | :: Spring Boot :: (v2.6.3)
docker-compose-api-1 |
docker-compose-api-1 | 2022-06-22 18:55:31.261 INFO 1 --- [ main] c.e.infrastock.InfraStockApplication : Starting InfraStockApplication v0.0.1-SNAPSHOT using Java 11.0.15.1 on a109f4fe4312 with PID 1 (/workspace/BOOT-INF/classes started by cnb in /workspace)
docker-compose-api-1 | 2022-06-22 18:55:31.270 INFO 1 --- [ main] c.e.infrastock.InfraStockApplication : No active profile set, falling back to default profiles: default
docker-compose-api-1 | 2022-06-22 18:55:32.883 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
docker-compose-api-1 | 2022-06-22 18:55:33.021 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 124 ms. Found 4 JPA repository interfaces.
docker-compose-api-1 | 2022-06-22 18:55:34.554 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9090 (http)
docker-compose-api-1 | 2022-06-22 18:55:34.583 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
docker-compose-api-1 | 2022-06-22 18:55:34.584 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.56]
docker-compose-api-1 | 2022-06-22 18:55:34.777 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
docker-compose-api-1 | 2022-06-22 18:55:34.777 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3377 ms
docker-compose-api-1 | Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
docker-compose-api-1 | 2022-06-22 18:55:35.258 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
docker-compose-api-1 | 2022-06-22 18:55:35.367 INFO 1 --- [ main] org.hibernate.Version
: HHH000412: Hibernate ORM core version 5.6.4.Final
docker-compose-api-1 | 2022-06-22 18:55:35.583 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
docker-compose-api-1 | 2022-06-22 18:55:35.753 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
docker-compose-api-1 | 2022-06-22 18:55:35.772 WARN 1 --- [ main] com.zaxxer.hikari.util.DriverDataSource : Registered driver with driverClassName=com.mysql.jdbc.Driver was not found, trying direct instantiation.
docker-compose-api-1 | 2022-06-22 18:55:36.976 ERROR 1 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
docker-compose-api-1 |
docker-compose-api-1 | com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
docker-compose-api-1 |
docker-compose-api-1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
docker-compose-api-1 | at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) ~[mysql-connector-java-8.0.28.jar:8.0.28]
docker-compose-api-1 | at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) ~[mysql-connector-java-8.0.28.jar:8.0.28]
docker-compose-api-1 | at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:829) ~[mysql-connector-java-8.0.28.jar:8.0.28]
docker-compose-api-1 | at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:449) ~[mysql-connector-java-8.0.28.jar:8.0.28]
docker-compose-api-1 | at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:242) ~[mysql-connector-java-8.0.28.jar:8.0.28]
docker-compose-api-1 | at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) ~[mysql-connector-java-8.0.28.jar:8.0.28]
docker-compose-api-1 | at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:121) ~[HikariCP-4.0.3.jar:na]
docker-compose-api-1 | at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364) ~[HikariCP-4.0.3.jar:na]
docker-compose-api-1 | at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) ~[HikariCP-4.0.3.jar:na]
docker-compose-api-1 | at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476) ~[HikariCP-4.0.3.jar:na]
docker-compose-api-1 | at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) ~[HikariCP-4.0.3.jar:na]
docker-compose-api-1 | at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[HikariCP-4.0.3.jar:na]
docker-compose-api-1 | at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-4.0.3.jar:na]
docker-compose-api-1 | at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:181) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:175) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:173) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:127) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1460) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1494) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
docker-compose-api-1 | at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.15.jar:5.3.15]
docker-compose-api-1 | at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.15.jar:5.3.15]
docker-compose-api-1 | at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.15.jar:5.3.15]
docker-compose-api-1 | at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.15.jar:5.3.15]
docker-compose-api-1 | at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.3.15.jar:5.3.15]
docker-compose-api-1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.15.jar:5.3.15]
docker-compose-api-1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.15.jar:5.3.15]
docker-compose-api-1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.15.jar:5.3.15]
docker-compose-api-1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar:5.3.15]
docker-compose-api-1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar:5.3.15]
docker-compose-api-1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar:5.3.15]
docker-compose-api-1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar:5.3.15]
docker-compose-api-1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
docker-compose-api-1 | at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.15.jar:5.3.15]
docker-compose-api-1 | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.15.jar:5.3.15]
docker-compose-api-1 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.15.jar:5.3.15]
Full stack trace: https://pastebin.com/mLPfHNbJ
Full docker-compose.yml logslogs

Related

Docker postgres java.io.EOFException: null when trying to connect

I have my Dockerfile and docker-compose.yml configured to start my two services - this is my postgres db and Spring Boot app.
Dockerfile:
FROM openjdk:8-jdk-alpine
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
COPY ./init.dump /docker-entrypoint-initdb.d/
RUN chmod 0755 /docker-entrypoint-initdb.d/init.dump
COPY target/endlessblow-server-1.0-SNAPSHOT.jar /
COPY endless-blow-firebase.json /
EXPOSE 8000
CMD ["java", "-jar", "endlessblow-server-1.0-SNAPSHOT.jar"]
docker-compose.yml
version: "3.5"
services:
endlessblowapp_container:
build: .
image: endlessblowapp
container_name: endlessblowapp_container
ports:
- "8080:8080"
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://host.docker.internal:5430/endlessblow_db
restart: on-failure
depends_on:
- endlessblowdb_container
endlessblowdb_container:
image: postgres:14-alpine
container_name: endlessblowdb_container
command: -c 'max_connections=250'
ports:
- "5430:5432"
environment:
POSTGRES_DB: endlessblow_db
POSTGRES_USER: kuba
POSTGRES_PASSWORD: admin
volumes:
- ./init.dump:/docker-entrypoint-initdb.d/init.dump
application.properties
spring.datasource.url=jdbc:postgresql://host.docker.internal:5430/endlessblow_db
spring.datasource.username=kuba
spring.datasource.password=admin
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
Now, the problem is once the containers are starting and db container is started, the container with Spring Boot app still fails to be started due to this exception:
Caused by: java.io.EOFException: null
at org.postgresql.core.PGStream.receiveChar(PGStream.java:455) ~[postgresql-42.5.0.jar!/:42.5.0]
at org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactoryImpl.java:553) ~[postgresql-42.5.0.jar!/:42.5.0]
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:168) ~[postgresql-42.5.0.jar!/:42.5.0]
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:235) ~[postgresql-42.5.0.jar!/:42.5.0]
... 57 common frames omitted
.
Here I am attaching full Spring Boot container log:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.3)
2022-10-05 10:49:04.695 INFO 1 --- [ main] pl.jawegiel.Main : Starting Main v1.0-SNAPSHOT using Java 1.8.0_212 on f347c0966ca7 with PID 1 (/endlessblow-server-1.0-SNAPSHOT.jar started by root in /)
2022-10-05 10:49:04.699 INFO 1 --- [ main] pl.jawegiel.Main : No active profile set, falling back to default profiles: default
2022-10-05 10:49:07.123 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-10-05 10:49:07.156 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 18 ms. Found 0 JPA repository interfaces.
2022-10-05 10:49:08.845 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-10-05 10:49:08.864 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-10-05 10:49:08.865 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.43]
2022-10-05 10:49:08.948 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-10-05 10:49:08.949 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4102 ms
2022-10-05 10:49:09.497 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-10-05 10:49:10.621 ERROR 1 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:331) ~[postgresql-42.5.0.jar!/:42.5.0]
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.5.0.jar!/:42.5.0]
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:247) ~[postgresql-42.5.0.jar!/:42.5.0]
at org.postgresql.Driver.makeConnection(Driver.java:434) ~[postgresql-42.5.0.jar!/:42.5.0]
at org.postgresql.Driver.connect(Driver.java:291) ~[postgresql-42.5.0.jar!/:42.5.0]
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-3.4.5.jar!/:na]
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:358) ~[HikariCP-3.4.5.jar!/:na]
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) ~[HikariCP-3.4.5.jar!/:na]
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:477) [HikariCP-3.4.5.jar!/:na]
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:560) [HikariCP-3.4.5.jar!/:na]
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) [HikariCP-3.4.5.jar!/:na]
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) [HikariCP-3.4.5.jar!/:na]
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:158) [spring-jdbc-5.3.4.jar!/:5.3.4]
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:116) [spring-jdbc-5.3.4.jar!/:5.3.4]
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79) [spring-jdbc-5.3.4.jar!/:5.3.4]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:330) [spring-jdbc-5.3.4.jar!/:5.3.4]
at org.springframework.boot.jdbc.EmbeddedDatabaseConnection.isEmbedded(EmbeddedDatabaseConnection.java:182) [spring-boot-2.4.3.jar!/:2.4.3]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateDefaultDdlAutoProvider.getDefaultDdlAuto(HibernateDefaultDdlAutoProvider.java:42) [spring-boot-autoconfigure-2.4.3.jar!/:2.4.3]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration.lambda$getVendorProperties$1(HibernateJpaConfiguration.java:130) [spring-boot-autoconfigure-2.4.3.jar!/:2.4.3]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateSettings.getDdlAuto(HibernateSettings.java:41) ~[spring-boot-autoconfigure-2.4.3.jar!/:2.4.3]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties.determineDdlAuto(HibernateProperties.java:136) ~[spring-boot-autoconfigure-2.4.3.jar!/:2.4.3]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties.getAdditionalProperties(HibernateProperties.java:102) ~[spring-boot-autoconfigure-2.4.3.jar!/:2.4.3]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties.determineHibernateProperties(HibernateProperties.java:94) ~[spring-boot-autoconfigure-2.4.3.jar!/:2.4.3]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration.getVendorProperties(HibernateJpaConfiguration.java:132) [spring-boot-autoconfigure-2.4.3.jar!/:2.4.3]
at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.entityManagerFactory(JpaBaseConfiguration.java:134) ~[spring-boot-autoconfigure-2.4.3.jar!/:2.4.3]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_212]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.4.jar!/:5.3.4]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.4.jar!/:5.3.4]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.4.jar!/:5.3.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1334) ~[spring-beans-5.3.4.jar!/:5.3.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.3.4.jar!/:5.3.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) ~[spring-beans-5.3.4.jar!/:5.3.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.4.jar!/:5.3.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.4.jar!/:5.3.4]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.4.jar!/:5.3.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.4.jar!/:5.3.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.4.jar!/:5.3.4]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1153) ~[spring-context-5.3.4.jar!/:5.3.4]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:907) ~[spring-context-5.3.4.jar!/:5.3.4]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:582) ~[spring-context-5.3.4.jar!/:5.3.4]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.3.jar!/:2.4.3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767) ~[spring-boot-2.4.3.jar!/:2.4.3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) ~[spring-boot-2.4.3.jar!/:2.4.3]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) ~[spring-boot-2.4.3.jar!/:2.4.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) ~[spring-boot-2.4.3.jar!/:2.4.3]
at pl.jawegiel.Main.main(Main.java:22) ~[classes!/:1.0-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_212]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[endlessblow-server-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:107) ~[endlessblow-server-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[endlessblow-server-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[endlessblow-server-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
Caused by: java.io.EOFException: null
at org.postgresql.core.PGStream.receiveChar(PGStream.java:455) ~[postgresql-42.5.0.jar!/:42.5.0]
at org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactoryImpl.java:553) ~[postgresql-42.5.0.jar!/:42.5.0]
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:168) ~[postgresql-42.5.0.jar!/:42.5.0]
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:235) ~[postgresql-42.5.0.jar!/:42.5.0]
... 56 common frames omitted
2022-10-05 10:49:10.823 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-10-05 10:49:11.034 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.28.Final
2022-10-05 10:49:11.296 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2022-10-05 10:49:11.468 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-10-05 10:49:12.479 ERROR 1 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
What's interesting is that when I try to connect to postgres container on pgAdmin it connects correctly.
Change
spring.datasource.url=jdbc:postgresql://host.docker.internal:5430/endlessblow_db
this to
spring.datasource.url=jdbc:postgresql://endlessblowdb_container:5432/endlessblow_db
This error is coming for wrong database password
and application properties will be :
spring.datasource.url=jdbc:postgresql://localhost:5432/<database name>
spring.datasource.username=<database user name>
spring.datasource.password=<database password>
Dialect for postgresSQL :
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation= true
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
Dialect for MySQL :
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation= true
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
Try this once.

WARN Cannot create filesystem for url jar:file:/app.jar!/BOOT-INF/classes!/: null java.nio.file.FileSystemNotFoundException: null

I tried to dockerize my spring boot application and achived this error
WARN Cannot create filesystem for url
jar:file:/app.jar!/BOOT-INF/classes!/: null
java.nio.file.FileSystemNotFoundException: null.
What am I doing wrong? Without docker application work fine.
Problem disappeared after I delete liquibase dependency from pom.xml What can be wrong with liquibase?
Dockerfile:
FROM openjdk:8-jdk-alpine
VOLUME /tmp
EXPOSE 8080
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]
Docker-compose:
version: '3.2'
services:
activemq:
image: rmohr/activemq:latest
network_mode: bridge
container_name: activemq
environment:
- ACTIVEMQ_USERNAME=admin
- ACTIVEMQ_PASSWORD=admin
restart: unless-stopped
simplewebapp:
image: simplewebapp
network_mode: bridge
container_name: simplewebapp
expose:
- 8080
ports:
- 8080:8080
restart: unless-stopped
depends_on:
- activemq
links:
- activemq
Running with docker build -t simplewebapp . and then docker-compose up and I am recieving this in console:
C:\Users\Vasiliev\Desktop\projects\simplewebapp>docker build -t simplewebapp .
Sending build context to Docker daemon 56.21MB
Step 1/7 : FROM openjdk:8-jdk-alpine
---> a3562aa0b991
Step 2/7 : MAINTAINER Vasiliev A
---> Using cache
---> 18f600863d67
Step 3/7 : VOLUME /tmp
---> Using cache
---> 23a191d44d82
Step 4/7 : EXPOSE 8080
---> Using cache
---> 853804494bea
Step 5/7 : ARG JAR_FILE=target/*.jar
---> Using cache
---> fd23891bd332
Step 6/7 : COPY ${JAR_FILE} app.jar
---> Using cache
---> 81c37844ac5b
Step 7/7 : ENTRYPOINT ["java", "-jar", "/app.jar"]
---> Using cache
---> 090cc2dd4775
Successfully built 090cc2dd4775
Successfully tagged simplewebapp:latest
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
and this after docker-compose up
C:\Users\Vasiliev\Desktop\projects\simplewebapp>docker-compose up
Starting activemq ... done
Recreating simplewebapp ... done
Attaching to activemq, simplewebapp
activemq | INFO: Loading '/opt/activemq/bin/env'
activemq | INFO: Using java '/docker-java-home/jre/bin/java'
activemq | bin/activemq: 1: bin/activemq: ps: not found
activemq | INFO: Starting in foreground, this is just for debugging purposes (stop process by pressing CTRL+C)
activemq | INFO: Creating pidfile /opt/activemq/data/activemq.pid
activemq | Java Runtime: Oracle Corporation 1.8.0_181 /usr/lib/jvm/java-8-openjdk-amd64/jre
activemq | Heap sizes: current=62976k free=58715k max=932352k
activemq | JVM args: -Xms64M -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/opt/activemq/conf/login.config -Dcom.sun.management.jmxremote -Djava.awt.headless=true -Djava.io.tmpdir=/opt/activemq/tmp -Dactivemq
.classpath=/opt/activemq/conf:/opt/activemq/../lib/: -Dactivemq.home=/opt/activemq -Dactivemq.base=/opt/activemq -Dactivemq.conf=/opt/activemq/conf -Dactivemq.data=/opt/activemq/data
activemq | Extensions classpath:
activemq | [/opt/activemq/lib,/opt/activemq/lib/camel,/opt/activemq/lib/optional,/opt/activemq/lib/web,/opt/activemq/lib/extra]
activemq | ACTIVEMQ_HOME: /opt/activemq
activemq | ACTIVEMQ_BASE: /opt/activemq
activemq | ACTIVEMQ_CONF: /opt/activemq/conf
activemq | ACTIVEMQ_DATA: /opt/activemq/data
activemq | Loading message broker from: xbean:activemq.xml
activemq | INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1#6e06451e: startup date [Thu Aug 13 01:34:45 UTC 2020]; root of context hierarchy
activemq | INFO | Using Persistence Adapter: KahaDBPersistenceAdapter[/opt/activemq/data/kahadb]
activemq | INFO | KahaDB is version 6
activemq | INFO | PListStore:[/opt/activemq/data/localhost/tmp_storage] started
activemq | INFO | Apache ActiveMQ 5.15.6 (localhost, ID:ba0d35ec1711-43371-1597282491343-0:1) is starting
activemq | INFO | Listening for connections at: tcp://ba0d35ec1711:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600
activemq | INFO | Connector openwire started
activemq | INFO | Listening for connections at: amqp://ba0d35ec1711:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600
activemq | INFO | Connector amqp started
activemq | INFO | Listening for connections at: stomp://ba0d35ec1711:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600
activemq | INFO | Connector stomp started
activemq | INFO | Listening for connections at: mqtt://ba0d35ec1711:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600
activemq | INFO | Connector mqtt started
activemq | WARN | ServletContext#o.e.j.s.ServletContextHandler#545b995e{/,null,STARTING} has uncovered http methods for path: /
activemq | INFO | Listening for connections at ws://ba0d35ec1711:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600
activemq | INFO | Connector ws started
activemq | INFO | Apache ActiveMQ 5.15.6 (localhost, ID:ba0d35ec1711-43371-1597282491343-0:1) started
activemq | INFO | For help or more information please see: http://activemq.apache.org
activemq | WARN | Store limit is 102400 mb (current store usage is 3 mb). The data directory: /opt/activemq/data/kahadb only has 49324 mb of usable space. - resetting to maximum available disk space: 49324 mb
activemq | WARN | Temporary Store limit is 51200 mb (current store usage is 0 mb). The data directory: /opt/activemq/data only has 49321 mb of usable space. - resetting to maximum available disk space: 49321 mb
simplewebapp | 2020-08-13 01:34:55,951 main INFO Log4j appears to be running in a Servlet environment, but there's no log4j-web module available. If you want better web container support, please add the log4j-web JAR to your web archive or server lib directory.
simplewebapp |
simplewebapp | . ____ _ __ _ _
simplewebapp | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
simplewebapp | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
simplewebapp | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
simplewebapp | ' |____| .__|_| |_|_| |_\__, | / / / /
simplewebapp | =========|_|==============|___/=/_/_/_/
simplewebapp | :: Spring Boot :: (v2.3.1.RELEASE)
simplewebapp |
activemq | INFO | No Spring WebApplicationInitializer types detected on classpath
simplewebapp | 2020-08-13T01:34:57.805+0000 INFO Starting AppConfiguration v0.0.1-SNAPSHOT on 938a401683ba with PID 1 (/app.jar started by root in /)
simplewebapp | 2020-08-13T01:34:57.897+0000 DEBUG Running with Spring Boot v2.3.1.RELEASE, Spring v5.2.7.RELEASE
simplewebapp | 2020-08-13T01:34:57.906+0000 INFO No active profile set, falling back to default profiles: default
activemq | INFO | ActiveMQ WebConsole available at http://0.0.0.0:8161/
activemq | INFO | ActiveMQ Jolokia REST API available at http://0.0.0.0:8161/api/jolokia/
activemq | INFO | Initializing Spring FrameworkServlet 'dispatcher'
activemq | INFO | No Spring WebApplicationInitializer types detected on classpath
activemq | INFO | jolokia-agent: Using policy access restrictor classpath:/jolokia-access.xml
simplewebapp | 2020-08-13T01:35:04.244+0000 INFO Bootstrapping Spring Data JPA repositories in DEFAULT mode.
simplewebapp | 2020-08-13T01:35:04.448+0000 INFO Finished Spring Data repository scanning in 134ms. Found 1 JPA repository interfaces.
simplewebapp | 2020-08-13T01:35:08.972+0000 INFO Tomcat initialized with port(s): 8080 (http)
simplewebapp | 2020-08-13T01:35:09.004+0000 INFO Initializing ProtocolHandler ["http-nio-8080"]
simplewebapp | 2020-08-13T01:35:09.006+0000 INFO Starting service [Tomcat]
simplewebapp | 2020-08-13T01:35:09.008+0000 INFO Starting Servlet engine: [Apache Tomcat/9.0.36]
simplewebapp | 2020-08-13T01:35:09.228+0000 INFO Initializing Spring embedded WebApplicationContext
simplewebapp | 2020-08-13T01:35:09.232+0000 INFO Root WebApplicationContext: initialization completed in 10816 ms
simplewebapp | 2020-08-13T01:35:10.228+0000 INFO employeedb - Starting...
simplewebapp | 2020-08-13T01:35:10.683+0000 INFO employeedb - Start completed.
simplewebapp | 2020-08-13T01:35:11.768+0000 INFO Successfully acquired change log lock
simplewebapp | 2020-08-13T01:35:11.870+0000 WARN Cannot create filesystem for url jar:file:/app.jar!/BOOT-INF/classes!/: null
simplewebapp | java.nio.file.FileSystemNotFoundException: null
simplewebapp | at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171) ~[zipfs.jar:1.8.0_212]
simplewebapp | at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157) ~[zipfs.jar:1.8.0_212]
simplewebapp | at java.nio.file.Paths.get(Paths.java:143) ~[?:1.8.0_212]
simplewebapp | at liquibase.resource.ClassLoaderResourceAccessor.loadRootPaths(ClassLoaderResourceAccessor.java:63) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.resource.ClassLoaderResourceAccessor.init(ClassLoaderResourceAccessor.java:47) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.resource.ClassLoaderResourceAccessor.openStreams(ClassLoaderResourceAccessor.java:94) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.resource.AbstractResourceAccessor.openStream(AbstractResourceAccessor.java:17) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.parser.core.yaml.YamlChangeLogParser.parse(YamlChangeLogParser.java:25) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:223) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Liquibase$1.run(Liquibase.java:194) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Scope.lambda$child$0(Scope.java:159) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Scope.child(Scope.java:170) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Scope.child(Scope.java:158) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Scope.child(Scope.java:137) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Liquibase.runInScope(Liquibase.java:1790) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Liquibase.update(Liquibase.java:183) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Liquibase.update(Liquibase.java:179) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:322) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:270) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) [spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) [spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) [spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1109) [spring-context-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) [spring-context-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) [spring-context-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
simplewebapp | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
simplewebapp | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
simplewebapp | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
simplewebapp | at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
simplewebapp | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
simplewebapp | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
simplewebapp | at com.mastery.java.task.config.AppConfiguration.main(AppConfiguration.java:13) [classes!/:0.0.1-SNAPSHOT]
simplewebapp | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
simplewebapp | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
simplewebapp | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
simplewebapp | at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
simplewebapp | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) [app.jar:0.0.1-SNAPSHOT]
simplewebapp | at org.springframework.boot.loader.Launcher.launch(Launcher.java:109) [app.jar:0.0.1-SNAPSHOT]
simplewebapp | at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) [app.jar:0.0.1-SNAPSHOT]
simplewebapp | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) [app.jar:0.0.1-SNAPSHOT]
simplewebapp | 2020-08-13T01:35:11.887+0000 WARN Cannot create filesystem for url jar:file:/app.jar!/BOOT-INF/lib/spring-boot-starter-web-2.3.1.RELEASE.jar!/: null
simplewebapp | java.nio.file.FileSystemNotFoundException: null
simplewebapp | at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171) ~[zipfs.jar:1.8.0_212]
simplewebapp | at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157) ~[zipfs.jar:1.8.0_212]
simplewebapp | at java.nio.file.Paths.get(Paths.java:143) ~[?:1.8.0_212]
simplewebapp | at liquibase.resource.ClassLoaderResourceAccessor.loadRootPaths(ClassLoaderResourceAccessor.java:63) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.resource.ClassLoaderResourceAccessor.init(ClassLoaderResourceAccessor.java:47) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.resource.ClassLoaderResourceAccessor.openStreams(ClassLoaderResourceAccessor.java:94) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.resource.AbstractResourceAccessor.openStream(AbstractResourceAccessor.java:17) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.parser.core.yaml.YamlChangeLogParser.parse(YamlChangeLogParser.java:25) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:223) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Liquibase$1.run(Liquibase.java:194) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Scope.lambda$child$0(Scope.java:159) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Scope.child(Scope.java:170) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Scope.child(Scope.java:158) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Scope.child(Scope.java:137) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Liquibase.runInScope(Liquibase.java:1790) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Liquibase.update(Liquibase.java:183) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.Liquibase.update(Liquibase.java:179) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:322) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:270) ~[liquibase-core-4.0.0.jar!/:?]
simplewebapp | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) [spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) [spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) [spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1109) [spring-context-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) [spring-context-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) [spring-context-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
simplewebapp | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
simplewebapp | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
simplewebapp | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
simplewebapp | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
simplewebapp | at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
simplewebapp | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
simplewebapp | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
simplewebapp | at com.mastery.java.task.config.AppConfiguration.main(AppConfiguration.java:13) [classes!/:0.0.1-SNAPSHOT]
simplewebapp | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
simplewebapp | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
simplewebapp | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
simplewebapp | at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
simplewebapp | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) [app.jar:0.0.1-SNAPSHOT]
simplewebapp | at org.springframework.boot.loader.Launcher.launch(Launcher.java:109) [app.jar:0.0.1-SNAPSHOT]
simplewebapp | at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) [app.jar:0.0.1-SNAPSHOT]
simplewebapp | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) [app.jar:0.0.1-SNAPSHOT]
Liquibase initializing DB and app works.

Docker connection refused error Spring boot + MariaDB

I am trying to connection MariaDB database using docker-compose, but I get the following error where I run containers using the command 'docker-compose up'
application.properties
spring.datasource.hikari.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
spring.datasource.hikari.jdbc-url=jdbc:log4jdbc:mariadb://kipit_db:${DATABASE_PORT}/${DATABASE_NAME}?useSSL=false&useUnicode=true&serverTimezone=Asia/Seoul&allowPublicKeyRetrieval=true
spring.datasource.hikari.username=${DATABASE_USER}
spring.datasource.hikari.password=${DATABASE_PASSWORD}
Dockerfile
FROM openjdk:8-jdk
VOLUME /tmp
EXPOSE 8080
ARG JAR_FILE=build/libs/kipit-0.0.1-SNAPSHOT.jar
ADD ${JAR_FILE} kipit.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/kipit.jar"]
docker-compose.yml
version: '3'
services:
kipit_db:
image: mariadb:10.4
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=test
- MYSQL_PASSWORD=root
kipit:
image: kipit
depends_on:
- kipit_db
ports:
- 8080:8080
- 3308:3306
environment:
- DATABASE_USER=root
- DATABASE_PASSWORD=root
- DATABASE_NAME=test
- DATABASE_PORT=3306
Set up a spring boot application that depends on a MariaDB called in docker-compose. After issuing docker-compose up I'm getting:
Error Log
Creating network "kipit_default" with the default driver
Creating kipit_kipit_db_1 ... done
Creating kipit_kipit_1 ... done
Attaching to kipit_kipit_db_1, kipit_kipit_1
kipit_db_1 | 2020-05-29 05:50:39+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.13+maria~bionic started.
kipit_db_1 | 2020-05-29 05:50:40+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
kipit_db_1 | 2020-05-29 05:50:40+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.13+maria~bionic started.
kipit_db_1 | 2020-05-29 05:50:40+00:00 [Note] [Entrypoint]: Initializing database files
kipit_1 |
kipit_1 | . ____ _ __ _ _
kipit_1 | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
kipit_1 | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
kipit_1 | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
kipit_1 | ' |____| .__|_| |_|_| |_\__, | / / / /
kipit_1 | =========|_|==============|___/=/_/_/_/
kipit_1 | :: Spring Boot :: (v2.2.6.RELEASE)
kipit_1 |
kipit_1 | 2020-05-29 05:50:42 INFO [ main ] c.p.k.KipitApplication : Starting KipitApplication on 0fe8f9293838 with PID 1 (/kipit.jar started by root in /)
kipit_1 | 2020-05-29 05:50:42 INFO [ main ] c.p.k.KipitApplication : The following profiles are active: oauth
kipit_db_1 |
kipit_db_1 |
kipit_db_1 | PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
kipit_db_1 | To do so, start the server, then issue the following commands:
kipit_db_1 |
kipit_db_1 | '/usr/bin/mysqladmin' -u root password 'new-password'
kipit_db_1 | '/usr/bin/mysqladmin' -u root -h password 'new-password'
kipit_db_1 |
kipit_db_1 | Alternatively you can run:
kipit_db_1 | '/usr/bin/mysql_secure_installation'
kipit_db_1 |
kipit_db_1 | which will also give you the option of removing the test
kipit_db_1 | databases and anonymous user created by default. This is
kipit_db_1 | strongly recommended for production servers.
kipit_db_1 |
kipit_db_1 | See the MariaDB Knowledgebase at http://mariadb.com/kb or the
kipit_db_1 | MySQL manual for more instructions.
kipit_db_1 |
kipit_db_1 | Please report any problems at http://mariadb.org/jira
kipit_db_1 |
kipit_db_1 | The latest information about MariaDB is available at http://mariadb.org/.
kipit_db_1 | You can find additional information about the MySQL part at:
kipit_db_1 | http://dev.mysql.com
kipit_db_1 | Consider joining MariaDB's strong and vibrant community:
kipit_db_1 | https://mariadb.org/get-involved/
kipit_db_1 |
kipit_db_1 | 2020-05-29 05:50:43+00:00 [Note] [Entrypoint]: Database files initialized
kipit_db_1 | 2020-05-29 05:50:43+00:00 [Note] [Entrypoint]: Starting temporary server
kipit_db_1 | 2020-05-29 05:50:43+00:00 [Note] [Entrypoint]: Waiting for server startup
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] mysqld (mysqld 10.4.13-MariaDB-1:10.4.13+maria~bionic) starting as process 122 ...
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Using Linux native AIO
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Uses event mutexes
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Number of pools: 1
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Using SSE2 crc32 instructions
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Completed initialization of buffer pool
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Creating shared tablespace for temporary tables
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Waiting for purge to start
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: 10.4.13 started; log sequence number 60972; transaction id 21
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] Plugin 'FEEDBACK' is disabled.
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
kipit_db_1 | 2020-05-29 5:50:44 0 [Warning] 'user' entry 'root#3787a6d6386a' ignored in --skip-name-resolve mode.
kipit_db_1 | 2020-05-29 5:50:44 0 [Warning] 'user' entry '#3787a6d6386a' ignored in --skip-name-resolve mode.
kipit_db_1 | 2020-05-29 5:50:44 0 [Warning] 'proxies_priv' entry '#% root#3787a6d6386a' ignored in --skip-name-resolve mode.
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Buffer pool(s) load completed at 200529 5:50:44
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] Reading of all Master_info entries succeeded
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] Added new Master_info '' to hash table
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] mysqld: ready for connections.
kipit_db_1 | Version: '10.4.13-MariaDB-1:10.4.13+maria~bionic' socket: '/var/run/mysqld/mysqld.sock' port: 0 mariadb.org binary distribution
kipit_db_1 | 2020-05-29 05:50:45+00:00 [Note] [Entrypoint]: Temporary server started.
kipit_1 | 2020-05-29 05:50:45 INFO [ main ] o.s.b.w.e.t.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
kipit_1 | 2020-05-29 05:50:45 INFO [ main ] o.a.c.h.Http11NioProtocol : Initializing ProtocolHandler ["http-nio-8080"]
kipit_1 | 2020-05-29 05:50:45 INFO [ main ] o.a.c.c.StandardService : Starting service [Tomcat]
kipit_1 | 2020-05-29 05:50:45 INFO [ main ] o.a.c.c.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.33]
kipit_1 | 2020-05-29 05:50:45 INFO [ main ] o.a.c.c.C.[.[.[/] : Initializing Spring embedded WebApplicationContext
kipit_1 | 2020-05-29 05:50:45 INFO [ main ] o.s.w.c.ContextLoader : Root WebApplicationContext: initialization completed in 2707 ms
kipit_1 | 2020-05-29 05:50:45 INFO [ main ] c.z.h.HikariDataSource : HikariPool-1 - Starting...
kipit_1 | 2020-05-29 05:50:47 ERROR[ main ] c.z.h.p.HikariPool : HikariPool-1 - Exception during pool initialization.
kipit_1 | java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=kipit_db)(port=3306)(type=master) : Socket fail to connect to host:kipit_db, port:3306. Conne
ction refused (Connection refused)
kipit_1 | at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:240)
kipit_1 | at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1192)
kipit_1 | at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:620)
kipit_1 | at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:175)
kipit_1 | at org.mariadb.jdbc.Driver.connect(Driver.java:92)
kipit_1 | at net.sf.log4jdbc.sql.jdbcapi.DriverSpy.connect(DriverSpy.java:401)
kipit_1 | at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
kipit_1 | at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354)
kipit_1 | at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202)
kipit_1 | at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473)
kipit_1 | at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:554)
kipit_1 | at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
kipit_1 | at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
kipit_1 | at com.project.kipit.config.DatabaseConfig.dataSource(DatabaseConfig.java:35)
kipit_1 | at com.project.kipit.config.DatabaseConfig$$EnhancerBySpringCGLIB$$37c12367.CGLIB$dataSource$1(<generated>)
kipit_1 | at com.project.kipit.config.DatabaseConfig$$EnhancerBySpringCGLIB$$37c12367$$FastClassBySpringCGLIB$$3aa2a57.invoke(<generated>)
kipit_1 | at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
kipit_1 | at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
kipit_1 | at com.project.kipit.config.DatabaseConfig$$EnhancerBySpringCGLIB$$37c12367.dataSource(<generated>)
kipit_1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
kipit_1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
kipit_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
kipit_1 | at java.lang.reflect.Method.invoke(Method.java:498)
kipit_1 | at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:484)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
kipit_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
kipit_1 | at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
kipit_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1290)
kipit_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1210)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:539)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
kipit_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
kipit_1 | at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
kipit_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1290)
kipit_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1210)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1511)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1406)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
kipit_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
kipit_1 | at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
kipit_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1290)
kipit_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1210)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:228)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1358)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1204)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
kipit_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
kipit_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:882)
kipit_1 | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
kipit_1 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
kipit_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
kipit_1 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
kipit_1 | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
kipit_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
kipit_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
kipit_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
kipit_1 | at com.project.kipit.KipitApplication.main(KipitApplication.java:20)
kipit_1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
kipit_1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
kipit_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
kipit_1 | at java.lang.reflect.Method.invoke(Method.java:498)
kipit_1 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
kipit_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
kipit_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
kipit_1 | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
kipit_1 | Caused by: java.sql.SQLNonTransientConnectionException: Socket fail to connect to host:kipit_db, port:3306. Connection refused (Connection refused)
kipit_1 | at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:240)
kipit_1 | at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.connException(ExceptionMapper.java:101)
kipit_1 | at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.createSocket(AbstractConnectProtocol.java:468)
kipit_1 | at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.createConnection(AbstractConnectProtocol.java:358)
kipit_1 | at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1187)
kipit_1 | ... 89 common frames omitted
kipit_1 | Caused by: java.net.ConnectException: Connection refused (Connection refused)
kipit_1 | at java.net.PlainSocketImpl.socketConnect(Native Method)
kipit_1 | at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
kipit_1 | at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
kipit_1 | at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
kipit_1 | at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
kipit_1 | at java.net.Socket.connect(Socket.java:607)
kipit_1 | at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.createSocket(AbstractConnectProtocol.java:463)
What i'am missing now? Thank you

Spring Boot and MySQL can't connect on Docker while using docker-compose - Shows "Failed to create/setup connection: Communications link failure"

I'm just trying to setup a starter project based on Spring Boot and MySQL using Docker. So I tried to run this github project on the Docker. But I am unable to establish connection between Java and MySQL.
I'm running Ubuntu 16.04.
I'm getting "Failed to create/setup connection: Communications link failure...." error while executing "docker-compose up" command.
Also this error doesn't show up if I use Docker Client. Like when I do as:
# 1. docker run -d -p 6033:3306 --name=docker-mysql --env="MYSQL_ROOT_PASSWORD=root" --env="MYSQL_PASSWORD=root" --env="MYSQL_DATABASE=book_manager" mysql
# 2. docker build -t springio/gs-spring-boot-docker .
# 3. docker run -t --link docker-mysql:mysql -p 10222:10222 springio/gs-spring-boot-docker
I tried to setup same environment through docker-compose but somehow its not working.
Below are the configuration details:
application.properties
logging.level.org.springframework=INFO
logging.level.com.mkyong=INFO
logging.level.com.zaxxer=DEBUG
logging.level.root=ERROR
logging.pattern.console=%-5level %logger{36} - %msg%n
## MySQL
spring.datasource.url=jdbc:mysql://docker-mysql:3306/book_manager
spring.datasource.username=root
spring.datasource.password=root
server.port=10222
connection.driver.class = com.mysql.jdbc.Driver
hibernate.dialect=org.hibernate.dialect.MySQLDialect
#`hibernate_sequence' doesn't exist
spring.jpa.hibernate.use-new-id-generator-mappings=false
hibernate.show_sql=false
#drop n create table again, good for testing, comment this in production
spring.jpa.hibernate.ddl-auto=create
Dockerfile for the java application container (service)
FROM openjdk:8-jdk-alpine
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} spring-data-jpa-mysql-1.0.jar
ENTRYPOINT ["java","-jar","/spring-data-jpa-mysql-1.0.jar"]
docker-compose.yml
version: '3'
services:
docker-mysql:
restart: always
container_name: docker-mysql
image: mysql
environment:
MYSQL_DATABASE: book_manager
MYSQL_ROOT_PASSWORD: root
ports:
- "6033:3306"
networks:
- spring-boot-mysql-network
book-manager-app:
build:
context: ./
dockerfile: Dockerfile
expose:
- "10222"
ports:
- "10222:10222"
depends_on:
- "docker-mysql"
networks:
- spring-boot-mysql-network
networks:
spring-boot-mysql-network:
driver: bridge
The following is the error log that I'm getting:
$/spring-data-jpa-mysql-compose$ docker-compose up
Creating network "spring-data-jpa-mysql-compose_spring-boot-mysql-network" with driver "bridge"
Creating docker-mysql ... done
Creating spring-data-jpa-mysql-compose_book-manager-app_1 ... done
Attaching to docker-mysql, spring-data-jpa-mysql-compose_book-manager-app_1
docker-mysql | 2020-04-07 13:44:39+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started.
docker-mysql | 2020-04-07 13:44:39+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
docker-mysql | 2020-04-07 13:44:39+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started.
docker-mysql | 2020-04-07 13:44:39+00:00 [Note] [Entrypoint]: Initializing database files
docker-mysql | 2020-04-07T13:44:39.855069Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
docker-mysql | 2020-04-07T13:44:39.855190Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.19) initializing of server in progress as process 42
book-manager-app_1 |
book-manager-app_1 | . ____ _ __ _ _
book-manager-app_1 | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
book-manager-app_1 | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
book-manager-app_1 | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
book-manager-app_1 | ' |____| .__|_| |_|_| |_\__, | / / / /
book-manager-app_1 | =========|_|==============|___/=/_/_/_/
book-manager-app_1 | :: Spring Boot :: (v2.1.2.RELEASE)
book-manager-app_1 |
book-manager-app_1 | INFO com.mkyong.StartApplication - Starting StartApplication v1.0 on 3638e84181ae with PID 1 (/spring-data-jpa-mysql-1.0.jar started by root in /)
book-manager-app_1 | INFO com.mkyong.StartApplication - No active profile set, falling back to default profiles: default
book-manager-app_1 | INFO o.s.d.r.c.RepositoryConfigurationDelegate - Bootstrapping Spring Data repositories in DEFAULT mode.
book-manager-app_1 | INFO o.s.d.r.c.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 134ms. Found 1 repository interfaces.
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - Driver class com.mysql.cj.jdbc.Driver found in Thread context class loader org.springframework.boot.loader.LaunchedURLClassLoader#5d099f62
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - HikariPool-1 - configuration:
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - allowPoolSuspension.............false
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - autoCommit......................true
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - catalog.........................none
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - connectionInitSql...............none
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - connectionTestQuery.............none
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - connectionTimeout...............30000
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - dataSource......................none
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - dataSourceClassName.............none
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - dataSourceJNDI..................none
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - dataSourceProperties............{password=<masked>}
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - driverClassName................."com.mysql.cj.jdbc.Driver"
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - healthCheckProperties...........{}
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - healthCheckRegistry.............none
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - idleTimeout.....................600000
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - initializationFailTimeout.......1
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - isolateInternalQueries..........false
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - jdbcUrl.........................jdbc:mysql://docker-mysql:3306/book_manager
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - leakDetectionThreshold..........0
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - maxLifetime.....................1800000
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - maximumPoolSize.................10
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - metricRegistry..................none
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - metricsTrackerFactory...........none
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - minimumIdle.....................10
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - password........................<masked>
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - poolName........................"HikariPool-1"
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - readOnly........................false
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - registerMbeans..................false
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - scheduledExecutor...............none
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - schema..........................none
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - threadFactory...................internal
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - transactionIsolation............default
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - username........................"root"
book-manager-app_1 | DEBUG com.zaxxer.hikari.HikariConfig - validationTimeout...............5000
book-manager-app_1 | INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
book-manager-app_1 | DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Failed to create/setup connection: Communications link failure
book-manager-app_1 |
book-manager-app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
book-manager-app_1 | DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Cannot acquire connection from data source
book-manager-app_1 | com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
book-manager-app_1 |
book-manager-app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
book-manager-app_1 | at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
book-manager-app_1 | at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
book-manager-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
book-manager-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455)
book-manager-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
book-manager-app_1 | at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:207)
book-manager-app_1 | at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:136)
book-manager-app_1 | at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:369)
book-manager-app_1 | at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:198)
book-manager-app_1 | at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:467)
book-manager-app_1 | at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:541)
book-manager-app_1 | at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
book-manager-app_1 | at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
book-manager-app_1 | at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:157)
book-manager-app_1 | at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115)
book-manager-app_1 | at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78)
book-manager-app_1 | at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:319)
book-manager-app_1 | at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:356)
book-manager-app_1 | at org.springframework.boot.autoconfigure.orm.jpa.DatabaseLookup.getDatabase(DatabaseLookup.java:73)
book-manager-app_1 | at org.springframework.boot.autoconfigure.orm.jpa.JpaProperties.determineDatabase(JpaProperties.java:142)
book-manager-app_1 | at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.jpaVendorAdapter(JpaBaseConfiguration.java:112)
book-manager-app_1 | at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration$$EnhancerBySpringCGLIB$$ff868e63.CGLIB$jpaVendorAdapter$8(<generated>)
book-manager-app_1 | at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration$$EnhancerBySpringCGLIB$$ff868e63$$FastClassBySpringCGLIB$$5875e117.invoke(<generated>)
book-manager-app_1 | at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
book-manager-app_1 | at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
book-manager-app_1 | at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration$$EnhancerBySpringCGLIB$$ff868e63.jpaVendorAdapter(<generated>)
book-manager-app_1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
book-manager-app_1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
book-manager-app_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
book-manager-app_1 | at java.lang.reflect.Method.invoke(Method.java:498)
book-manager-app_1 | at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
book-manager-app_1 | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
book-manager-app_1 | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
book-manager-app_1 | at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)
book-manager-app_1 | at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:91)
book-manager-app_1 | at com.mysql.cj.NativeSession.connect(NativeSession.java:152)
book-manager-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:955)
book-manager-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825)
book-manager-app_1 | ... 83 common frames omitted
book-manager-app_1 | Caused by: java.net.ConnectException: Connection refused (Connection refused)
book-manager-app_1 | at java.net.PlainSocketImpl.socketConnect(Native Method)
book-manager-app_1 | at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
book-manager-app_1 | at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
book-manager-app_1 | at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
book-manager-app_1 | at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
book-manager-app_1 | at java.net.Socket.connect(Socket.java:589)
book-manager-app_1 | at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155)
book-manager-app_1 | at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65)
book-manager-app_1 | ... 86 common frames omitted
book-manager-app_1 | ERROR com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Exception during pool initialization.
book-manager-app_1 | com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
book-manager-app_1 |
book-manager-app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
book-manager-app_1 | at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
book-manager-app_1 | at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
book-manager-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
book-manager-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455)
book-manager-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
book-manager-app_1 | at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:207)
book-manager-app_1 | at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:136)
book-manager-app_1 | at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:369)
book-manager-app_1 | at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:198)
book-manager-app_1 | at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:467)
book-manager-app_1 | at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:541)
book-manager-app_1 | at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
book-manager-app_1 | at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
book-manager-app_1 | at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:157)
book-manager-app_1 | at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115)
book-manager-app_1 | at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78)
book-manager-app_1 | at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:319)
book-manager-app_1 | at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:356)
book-manager-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127)
book-manager-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
book-manager-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
book-manager-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
book-manager-app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
book-manager-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
book-manager-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
book-manager-app_1 | at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083)
book-manager-app_1 | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:853)
book-manager-app_1 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
book-manager-app_1 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
book-manager-app_1 | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
book-manager-app_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
book-manager-app_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
book-manager-app_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
book-manager-app_1 | at com.mkyong.StartApplication.main(StartApplication.java:19)
book-manager-app_1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
book-manager-app_1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
book-manager-app_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
book-manager-app_1 | at java.lang.reflect.Method.invoke(Method.java:498)
book-manager-app_1 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
book-manager-app_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
book-manager-app_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
book-manager-app_1 | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
book-manager-app_1 | Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
book-org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
book-manager-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
book-manager-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
book-manager-app_1 | at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152)
book-manager-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286)
book-manager-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243)
book-manager-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
book-manager-app_1 | at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMertiesSet(AbstractEntityManagerFactoryBean.java:377)
book-manager-app_1 | at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341)
book-manager-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1804)
book-manager-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1741)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
book-manager-app_1 | at java.lang.reflect.Method.invoke(Method.java:498)
book-manager-app_1 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
book-manager-app_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
book-manager-app_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
book-manager-app_1 | at com.cketImpl.java:392)
book-manager-app_1 | at java.net.Socket.connect(Socket.java:589)
book-manager-app_1 | at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155)
book-manager-app_1 | at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65)
book-manager-app_1 | ... 59 common frames omitted
book-manager-app_1 | WARN o.s.c.a.AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
book-manager-app_1 | INFO o.s.b.a.l.ConditionEvaluationReportLoggingListener -
book-manager-app_1 |
book-manager-app_1 | Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
book-manager-app_1 | ERROR o.s.boot.SpringApplication - Application run failed
book-manager-app_1 | org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
book-manager-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1745)
book-manager-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576)
book-manager-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(Abstractorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:853)
book-manager-app_1 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
book-manager-app_1 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
book-manager-app_1 | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
book-manager-app_1 | Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
book-manager-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:275)
book-manager-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
book-manager-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
book-manager-app_1 | at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentityManagerFactoryBuilderImpl.java:904)
book-manager-app_1 | at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:935)
book-manager-app_1 | at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityMaAbstractEntityManagerFactoryBean.java:377)
book-manager-app_1 | at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341)
book-manager-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1804)
book-manager-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1741)
book-manager-app_1 | ... 23 common frames omitted
book-manager-app_1 | Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
book-manager-app_1 | at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImporg.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:94)
book-manager-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
book-manager-app_1 | ... 40 common frames omitted
spring-data-jpa-mysql-compose_book-manager-app_1 exited with code 1

Docker-Compose Java Springboot and MySQL

I try to use docker-compose to containerize with starting MySQL server container first, and then start a Springboot Container to connect with the MySQL container.
But the Connection is fail(See full version in the terminal log below
web_1 | com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
How should I make changes to start my MySQL container first, then link it the Springboot Server to MySQL?
My terminal log
$ docker-compose up
Creating network "backend_default" with the default driver
Creating backend_db_1 ... done
Creating backend_web_1 ... done
Attaching to backend_db_1, backend_web_1
db_1 | 2020-03-15 05:59:09+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started.
db_1 | 2020-03-15 05:59:09+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db_1 | 2020-03-15 05:59:09+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started.
web_1 | Trying to connect to MySQL at db:3306...
db_1 | 2020-03-15 05:59:09+00:00 [Note] [Entrypoint]: Initializing database files
web_1 | /wrapper.sh: connect: Connection refused
web_1 | /wrapper.sh: line 2: /dev/tcp/db/3306: Connection refused
db_1 | 2020-03-15T05:59:09.686844Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
db_1 | 2020-03-15T05:59:09.686961Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.19) initializing of server in progress as process 43
db_1 | 2020-03-15T05:59:12.938749Z 5 [Warning] [MY-010453] [Server] root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
db_1 | 2020-03-15 05:59:16+00:00 [Note] [Entrypoint]: Database files initialized
db_1 | 2020-03-15 05:59:16+00:00 [Note] [Entrypoint]: Starting temporary server
db_1 | 2020-03-15T05:59:17.100779Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
db_1 | 2020-03-15T05:59:17.100921Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 93
db_1 | 2020-03-15T05:59:17.688885Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
db_1 | 2020-03-15T05:59:17.692200Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
db_1 | 2020-03-15T05:59:17.730154Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.19' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server - GPL.
db_1 | 2020-03-15 05:59:17+00:00 [Note] [Entrypoint]: Temporary server started.
db_1 | 2020-03-15T05:59:17.802956Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock'
db_1 | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
db_1 | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
web_1 | /wrapper.sh: connect: Connection refused
web_1 | /wrapper.sh: line 2: /dev/tcp/db/3306: Connection refused
web_1 | Trying to connect to MySQL at db:3306...
db_1 | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
db_1 | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
db_1 | 2020-03-15 05:59:24+00:00 [Note] [Entrypoint]: Creating database dog_of_the_dow_app
db_1 | 2020-03-15 05:59:24+00:00 [Note] [Entrypoint]: Creating user shihao
db_1 | 2020-03-15 05:59:24+00:00 [Note] [Entrypoint]: Giving user shihao access to schema dog_of_the_dow_app
db_1 |
db_1 | 2020-03-15 05:59:24+00:00 [Note] [Entrypoint]: Stopping temporary server
db_1 | 2020-03-15T05:59:24.460353Z 14 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.19).
db_1 | 2020-03-15T05:59:25.812000Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.19) MySQL Community Server - GPL.
db_1 | 2020-03-15 05:59:26+00:00 [Note] [Entrypoint]: Temporary server stopped
db_1 |
db_1 | 2020-03-15 05:59:26+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
db_1 |
db_1 | 2020-03-15T05:59:26.755391Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
db_1 | 2020-03-15T05:59:26.755538Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 1
db_1 | 2020-03-15T05:59:27.241304Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
db_1 | 2020-03-15T05:59:27.245423Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
db_1 | 2020-03-15T05:59:27.270535Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.19' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
db_1 | 2020-03-15T05:59:27.417150Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
web_1 | >> connected to MySQL database! <<
web_1 |
web_1 | . ____ _ __ _ _
web_1 | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
web_1 | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
web_1 | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
web_1 | ' |____| .__|_| |_|_| |_\__, | / / / /
web_1 | =========|_|==============|___/=/_/_/_/
web_1 | :: Spring Boot :: (v2.2.4.RELEASE)
web_1 |
web_1 | 2020-03-15 05:59:32.794 INFO 8 --- [ main] c.s.a.w.d.DogOfTheDowAppApplication : Starting DogOfTheDowAppApplication v0.0.1-SNAPSHOT on 754a319ebef1 with PID 8 (/app.jar started by root in /)
web_1 | 2020-03-15 05:59:32.811 INFO 8 --- [ main] c.s.a.w.d.DogOfTheDowAppApplication : The following profiles are active: containers
web_1 | 2020-03-15 05:59:34.732 INFO 8 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
web_1 | 2020-03-15 05:59:34.886 INFO 8 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 131ms. Found 2 JPA repository interfaces.
web_1 | 2020-03-15 05:59:35.721 INFO 8 --- [ 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)
web_1 | 2020-03-15 05:59:36.338 INFO 8 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
web_1 | 2020-03-15 05:59:36.375 INFO 8 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
web_1 | 2020-03-15 05:59:36.376 INFO 8 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.30]
web_1 | 2020-03-15 05:59:36.528 INFO 8 --- [ main] o.a.c.c.C.[.[.[/mobile-app-ws] : Initializing Spring embedded WebApplicationContext
web_1 | 2020-03-15 05:59:36.529 INFO 8 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3531 ms
web_1 | 2020-03-15 05:59:37.363 INFO 8 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
web_1 | 2020-03-15 05:59:37.588 INFO 8 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.4.10.Final}
web_1 | 2020-03-15 05:59:38.015 INFO 8 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
web_1 | 2020-03-15 05:59:38.325 INFO 8 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
web_1 | 2020-03-15 05:59:39.613 ERROR 8 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
web_1 |
web_1 | com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
web_1 |
web_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
web_1 | at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
web_1 | at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
...
....
web_1 |
backend_web_1 exited with code 1
My Dockerfile
Download required images
and run the wrapper.sh
wrapper.sh will keep checking if the mysql container is successfully running
if so, than start the springboot, otherwise not
FROM openjdk:8-jdk-alpine
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ARG SH_FILE=src/main/resources/*.sh
COPY ${SH_FILE} wrapper.sh
RUN /bin/sh -c "apk add --no-cache bash"
RUN bash -c 'touch /app.jar'
RUN bash -c 'chmod +x /wrapper.sh'
ENTRYPOINT ["/bin/bash", "/wrapper.sh"]
My wrapper.sh file
keep checking mysql server
#!/usr/bin/env bash
while ! exec 6<>/dev/tcp/${DATABASE_HOST}/${DATABASE_PORT}; do
echo "Trying to connect to MySQL at ${DATABASE_HOST}:${DATABASE_PORT}..."
sleep 10
done
echo ">> connected to MySQL database! <<"
java -Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=containers -jar /app.jar
My docker-compose file
version: "2"
services:
db:
image: mysql:latest
environment:
- MYSQL_ROOT_PASSWORD=rootpassword
- MYSQL_DATABASE=example
- MYSQL_USER=shihao
- MYSQL_PASSWORD=shihao
ports:
- 3306:3306
web:
image: xli68/dog_of_the_dow:latest
depends_on:
- db
ports:
- 8080:8080
environment:
- DATABASE_HOST=db
- DATABASE_USER=shihao
- DATABASE_PASSWORD=shihao
- DATABASE_NAME=dog_of_the_dow_app
- DATABASE_PORT=3306

Categories