Dockerization of SpringBoot-Microservice, + Angular + MySQL + RabbitMQ - spring

I'm learning docker. While deploying my application(Angular, SpringBoot, RabbitMQ, MySQL), I'm able to access UI, but services are getting failed due to connection error between services and MySQL and RabbitMq. But individually I'm able to access both MySql and RabbitMq through docker exec command also tables and queues are getting generating while docker-compose up. But while testing, its not working
docker-compose.yml
version: '3.1'
services:
rabbitmq:
image: rabbitmq:management
ports:
- 5672:5672
- 15672:15672
mysql:
image: mysql:8.0.17
ports:
- 3306:3306
environment:
MYSQL_DATABASE: stackroute
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: cmatches
MYSQL_PASSWORD: cmatches
user-app:
image: userservice
build: userservice/
ports:
- 9100:9100
depends_on:
- mysql
network_mode: "host"
fav-app:
image: favouriteservice
build: favouriteservice/
ports:
- 9200:9200
depends_on:
- mysql
- rabbitmq
network_mode: "host"
rec-app:
image: matchrecommendationservice
build: matchrecommendationservice/
ports:
- 9300:9300
depends_on:
- mysql
- rabbitmq
network_mode: "host"
cmatches-ui:
build: CMatchesUI/
container_name: cmatchesUi
ports:
- 4200:4200
Individual dockerfile is working fine.
Error:
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
Do I need to change something in application.properties
server.port=9200
spring.datasource.url=jdbc:mysql://localhost:3306/stackroute?verifyServerCertificate=false&useSSL=false&requireSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=password
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto = update
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
spring.cloud.stream.bindings.recommendedMatchesChannel.destination=recommendedMatches
spring.cloud.stream.default.contentType=application/json
=========================================================================
Updates:
1.
Tried changing
spring.datasource.url=jdbc:mysql://mysql:3306/stackroute?verifyServerCertificate=false&useSSL=false&requireSSL=false&allowPublicKeyRetrieval=true
Got following error :
Caused by: java.net.UnknownHostException: mysql
-Reverted-
2.
Removed network_mode: host
got following error
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
user-app_1 |
user-app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
user-app_1 | at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:827) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:447) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:237) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:136) ~[HikariCP-3.2.0.jar!/:na]
user-app_1 | at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:369) ~[HikariCP-3.2.0.jar!/:na]
user-app_1 | at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:198) ~[HikariCP-3.2.0.jar!/:na]
user-app_1 | at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:467) [HikariCP-3.2.0.jar!/:na]
user-app_1 | at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:541) [HikariCP-3.2.0.jar!/:na]
user-app_1 | at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) [HikariCP-3.2.0.jar!/:na]
user-app_1 | at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) [HikariCP-3.2.0.jar!/:na]
user-app_1 | at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:94) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:179) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:119) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:904) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:935) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) [spring-orm-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) [spring-orm-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390) [spring-orm-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) [spring-orm-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) [spring-orm-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1804) [spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1741) [spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576) [spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) [spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) [spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) [spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) [spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:853) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
user-app_1 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
user-app_1 | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
user-app_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
user-app_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
user-app_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
user-app_1 | at com.stackroute.userservice.UserServiceApplication.main(UserServiceApplication.java:10) ~[classes!/:1.0]
user-app_1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_111]
user-app_1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_111]
user-app_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_111]
user-app_1 | at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_111]
user-app_1 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) ~[userservice-1.0.jar:1.0]
user-app_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[userservice-1.0.jar:1.0]
user-app_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) ~[userservice-1.0.jar:1.0]
user-app_1 | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) ~[userservice-1.0.jar:1.0]
user-app_1 | Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
user-app_1 |
user-app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
user-app_1 | at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_111]
user-app_1 | at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_111]
user-app_1 | at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_111]
user-app_1 | at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_111]
user-app_1 | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:91) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.NativeSession.connect(NativeSession.java:150) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:947) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:817) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | ... 57 common frames omitted
user-app_1 | Caused by: java.net.ConnectException: Connection refused (Connection refused)
user-app_1 | at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_111]
user-app_1 | at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_111]
user-app_1 | at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_111]
user-app_1 | at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_111]
user-app_1 | at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_111]
user-app_1 | at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_111]
user-app_1 | at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | ... 60 common frames omitted

You can't use localhost as the host name since the applications are run in a docker container. Also, to communicate each other, all the containers should be in the same docker network;
version: '3.1'
services:
rabbitmq:
image: rabbitmq:management
container_name: rabbitmq
ports:
- 5672:5672
- 15672:15672
networks:
- my-net
mysql:
image: mysql:8.0.17
container_name: mysql
ports:
- 3306:3306
environment:
MYSQL_DATABASE: stackroute
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: cmatches
MYSQL_PASSWORD: cmatches
networks:
- my-net
user-app:
image: userservice
build: userservice/
container_name: userapp
ports:
- 9100:9100
depends_on:
- mysql
networks:
- my-net
fav-app:
image: favouriteservice
build: favouriteservice/
container_name: favapp
ports:
- 9200:9200
depends_on:
- mysql
- rabbitmq
networks:
- my-net
rec-app:
image: matchrecommendationservice
build: matchrecommendationservice/
container_name: recapp
ports:
- 9300:9300
depends_on:
- mysql
- rabbitmq
networks:
- my-net
cmatches-ui:
build: CMatchesUI/
container_name: cmatchesUi
ports:
- 4200:4200
networks:
- my-net
networks:
my-net:
Replace host name in all places to their respective container names like this;
server.port=9200
spring.datasource.url=jdbc:mysql://mysql:3306/stackroute?verifyServerCertificate=false&useSSL=false&requireSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=password
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto = update
spring.rabbitmq.host=rabbitmq
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
spring.cloud.stream.bindings.recommendedMatchesChannel.destination=recommendedMatches
spring.cloud.stream.default.contentType=application/json

I think this is because you use network_mode = host
This means that you would like to "reuse" the namespace from the underlying host network.
Try to use the default "bridge" mode so that docker will create a "virtual network" between the containers.
This bridge mode is the default one, so just remove the line network_mode: "host" from the docker compose file.
Here is one nice tutorial that descibes docker network support at the high level.

Related

How do i solve this error : Caused by: org.postgresql.util.PSQLException: The connection attempt failed.?

orders | Caused by: org.postgresql.util.PSQLException: The connection attempt failed.
orders | at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:331) ~[postgresql-42.5.1.jar!/:42.5.1]
orders | at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.5.1.jar!/:42.5.1]
orders | at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:247) ~[postgresql-42.5.1.jar!/:42.5.1]
orders | at org.postgresql.Driver.makeConnection(Driver.java:434) ~[postgresql-42.5.1.jar!/:42.5.1]
orders | at org.postgresql.Driver.connect(Driver.java:291) ~[postgresql-42.5.1.jar!/:42.5.1]
orders | at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-4.0.3.jar!/:na]
orders | at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364) ~[HikariCP-4.0.3.jar!/:na]
orders | at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) ~[HikariCP-4.0.3.jar!/:na]
orders | at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476) ~[HikariCP-4.0.3.jar!/:na]
orders | at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) ~[HikariCP-4.0.3.jar!/:na]
orders | at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[HikariCP-4.0.3.jar!/:na]
orders | at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-4.0.3.jar!/:na]
orders | at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) ~[hibernate-core-5.6.14.Final.jar!/:5.6.14.Final]
orders | at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:181) ~[hibernate-core-5.6.14.Final.jar!/:5.6.14.Final]
orders | at org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl.getIsolatedConnection(DdlTransactionIsolatorNonJtaImpl.java:44) ~[hibernate-core-5.6.14.Final.jar!/:5.6.14.Final]
orders | ... 43 common frames omitted
I want to dockirize my application spring boot but is unable to connect to a PostgreSQL database.
Lien github https://github.com/Hasnaoui-Said/docker-compose-cloud-feign-eureka

Invalid HTTP Host: Kafka ElasticSearch Sink Connector

I am trying to use elasticsearch as a db for my application by using kafka connect in between. KafkaConnect, elasticsearch(version 7) and my application are running in a containers in a same network. When I trie to access elasticsearch from the container for kafkaconnect, it is successful. But my connector keeps throwing me the following error and I can't seem to figure out the exact issue:
Error:
container_standalone | java.lang.IllegalArgumentException: Invalid HTTP host: elasticsearch:9200/
container_standalone | at org.apache.http.HttpHost.create(HttpHost.java:123)
container_standalone | at io.confluent.connect.elasticsearch.jest.JestElasticsearchClient.lambda$getClientConfig$0(JestElasticsearchClient.java:201)
container_standalone | at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
container_standalone | at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
container_standalone | at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
container_standalone | at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
container_standalone | at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
container_standalone | at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
container_standalone | at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
container_standalone | at io.confluent.connect.elasticsearch.jest.JestElasticsearchClient.getClientConfig(JestElasticsearchClient.java:201)
container_standalone | at io.confluent.connect.elasticsearch.jest.JestElasticsearchClient.<init>(JestElasticsearchClient.java:149)
container_standalone | at io.confluent.connect.elasticsearch.jest.JestElasticsearchClient.<init>(JestElasticsearchClient.java:142)
container_standalone | at io.confluent.connect.elasticsearch.ElasticsearchSinkTask.start(ElasticsearchSinkTask.java:122)
container_standalone | at io.confluent.connect.elasticsearch.ElasticsearchSinkTask.start(ElasticsearchSinkTask.java:51)
container_standalone | at org.apache.kafka.connect.runtime.WorkerSinkTask.initializeAndStart(WorkerSinkTask.java:300)
container_standalone | at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:189)
container_standalone | at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:177)
container_standalone | at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:227)
container_standalone | at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
container_standalone | at java.util.concurrent.FutureTask.run(FutureTask.java:266)
container_standalone | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
container_standalone | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
container_standalone | at java.lang.Thread.run(Thread.java:748)
container_standalone | [2020-09-23 09:47:09,366] ERROR WorkerSinkTask{id=elasticsearch-sink-0} Task is being killed and will not recover until manually restarted (org.apache.kafka.connect.runtime.WorkerTask:180)
Configuration File:
name=elasticsearch-sink
connector.class=io.confluent.connect.elasticsearch.ElasticsearchSinkConnector
tasks.max=1
topics=vehicle
topic.index=test-vehicle
connection.url=http://elasticsearch:9200
connection.username=username
connection.password=password
type.name=log
key.ignore=true
schema.ignore=true
Elastic.yml file:
cluster.name: "docker-cluster"
network.host: 0.0.0.0
xpack.license.self_generated.type: trial
xpack.security.enabled: false
xpack.monitoring.collection.enabled: true

Spring Boot App container cannot connect to MySQl container

I am trying to containerize my Spring Boot app to work with multiple environments (production and dev). In my dev environment, I use docker-compose to start up an instance of MySQL server which my Spring Boot app is able to connect to when it is running outside a container but when my Spring Boot app is running in a container, it is unable to connect to the MySQL server.
This is the error I get when I run docker-compose up.
app_1 | 19:48:07.708 ERROR -- [ main] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'sessionRepositoryFilterRegistration' defined in class path resource [org/springframework/boot/autoconfigure/session/SessionRepositoryFilterConfiguration.class]: Unsatisfied dependency expressed through method 'sessionRepositoryFilterRegistration' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration': Unsatisfied dependency expressed through method 'setTransactionManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.exception.FlywaySqlException:
app_1 | Unable to obtain connection from database (jdbc:mysql://localhost:3306/app) for user 'root': Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
app_1 | SQL State : 08S01
app_1 | Error Code : 0
app_1 | Message : Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 |
app_1 | 19:48:07.736 INFO -- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
app_1 | 19:48:07.740 WARN -- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
app_1 | 19:48:07.751 INFO -- [ main] ConditionEvaluationReportLoggingListener :
app_1 |
app_1 | Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
app_1 | 19:48:07.757 ERROR -- [ main] o.s.boot.SpringApplication : Application run failed
app_1 |
app_1 | org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:157)
app_1 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
app_1 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
app_1 | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
app_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
app_1 | at com.brand.app.AppApp.main(AppApp.java:28)
app_1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
app_1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
app_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
app_1 | at java.lang.reflect.Method.invoke(Method.java:498)
app_1 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
app_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
app_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
app_1 | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
app_1 | Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
app_1 | at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:125)
app_1 | at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86)
app_1 | at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:427)
app_1 | at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:180)
app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181)
app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154)
app_1 | ... 14 common frames omitted
app_1 | Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionRepositoryFilterRegistration' defined in class path resource [org/springframework/boot/autoconfigure/session/SessionRepositoryFilterConfiguration.class]: Unsatisfied dependency expressed through method 'sessionRepositoryFilterRegistration' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration': Unsatisfied dependency expressed through method 'setTransactionManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.exception.FlywaySqlException:
app_1 | Unable to obtain connection from database (jdbc:mysql://localhost:3306/app) for user 'root': Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
app_1 | SQL State : 08S01
app_1 | Error Code : 0
app_1 | Message : Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 |
app_1 | at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769)
app_1 | at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
app_1 | at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:235)
app_1 | at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:226)
app_1 | at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:101)
app_1 | at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:88)
app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:261)
app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:234)
app_1 | at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:54)
app_1 | at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5139)
app_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
app_1 | at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
app_1 | at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
app_1 | at java.util.concurrent.FutureTask.run(FutureTask.java:266)
app_1 | at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
app_1 | at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
app_1 | at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
app_1 | at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831)
app_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
app_1 | at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
app_1 | at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
app_1 | at java.util.concurrent.FutureTask.run(FutureTask.java:266)
app_1 | at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
app_1 | at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
app_1 | at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
app_1 | at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
app_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
app_1 | at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423)
app_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
app_1 | at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:928)
app_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
app_1 | at org.apache.catalina.startup.Tomcat.start(Tomcat.java:455)
app_1 | at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:106)
app_1 | ... 19 common frames omitted
app_1 | Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration': Unsatisfied dependency expressed through method 'setTransactionManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.exception.FlywaySqlException:
app_1 | Unable to obtain connection from database (jdbc:mysql://localhost:3306/app) for user 'root': Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
app_1 | SQL State : 08S01
app_1 | Error Code : 0
app_1 | Message : Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 |
app_1 | at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:676)
app_1 | at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
app_1 | at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1411)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
app_1 | at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:392)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
app_1 | at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1247)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1167)
app_1 | at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
app_1 | at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
app_1 | ... 59 common frames omitted
app_1 | Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.exception.FlywaySqlException:
app_1 | Unable to obtain connection from database (jdbc:mysql://localhost:3306/app) for user 'root': Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
app_1 | SQL State : 08S01
app_1 | Error Code : 0
app_1 | Message : Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 |
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
app_1 | at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1247)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1167)
app_1 | at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:668)
app_1 | ... 82 common frames omitted
app_1 | Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.exception.FlywaySqlException:
app_1 | Unable to obtain connection from database (jdbc:mysql://localhost:3306/app) for user 'root': Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
app_1 | SQL State : 08S01
app_1 | Error Code : 0
app_1 | Message : Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 |
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:307)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:224)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1115)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:407)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:341)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:335)
app_1 | at org.springframework.orm.jpa.EntityManagerFactoryUtils.findEntityManagerFactory(EntityManagerFactoryUtils.java:120)
app_1 | at org.springframework.orm.jpa.JpaTransactionManager.setBeanFactory(JpaTransactionManager.java:313)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1800)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1765)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
app_1 | ... 91 common frames omitted
app_1 | Caused by: org.flywaydb.core.internal.exception.FlywaySqlException:
app_1 | Unable to obtain connection from database (jdbc:mysql://localhost:3306/app) for user 'root': Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
app_1 | SQL State : 08S01
app_1 | Error Code : 0
app_1 | Message : Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 |
app_1 | at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:60)
app_1 | at org.flywaydb.core.internal.database.DatabaseFactory.createDatabase(DatabaseFactory.java:72)
app_1 | at org.flywaydb.core.Flyway.execute(Flyway.java:1670)
app_1 | at org.flywaydb.core.Flyway.migrate(Flyway.java:1356)
app_1 | at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:66)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
app_1 | ... 108 common frames omitted
app_1 | Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 | at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
app_1 | at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
Here are some of the files involved.
docker-compose.yml - starts MySQL server and builds using a Dockerfile
Dockerfile - copies necessary files and runs entrypoint.sh
entrypoint.sh - starts the Spring Boot app jar
application.properties
application-dev.properties
docker-compose.yml
version: "3"
services:
app:
build:
context: ..
dockerfile: Dockerfile
args:
SPRING_PROFILES_ACTIVE: dev
image: app:dev
depends_on:
- mysql
mysql:
image: mysql:5.6
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: app
MYSQL_ROOT_PASSWORD: password
volumes:
- mysql_data:/var/lib/mysql/data
volumes:
mysql_data:
Dockerfile
FROM openjdk:8-jdk-alpine
ARG SPRING_PROFILES_ACTIVE=""
ENV SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE}
COPY target/app.jar /usr/share/
COPY script/entrypoint.sh /bin/entrypoint.sh
ENTRYPOINT /bin/entrypoint.sh
EXPOSE 5050
entrypoint.sh
#!/bin/sh
sleep 15
exec /usr/bin/java \
-jar /usr/share/app.jar \
--spring.profiles.active=${SPRING_PROFILES_ACTIVE}
Any idea why Spring Boot can't connect to MySQL server? Both containers should be on the same default network.
The Spring Boot app is trying to connect to jdbc:mysql://localhost:3306/app which is fine when the app isn't in a container but when it is in a container, localhost is not valid. The name of the MySQL server service is mysql (defined in the docker-compose.yml), so replacing localhost with mysql will resolve the issue.
For connecting from a docker service to another docker service like a database-service must be set local IP in docker-machine, in this state don't know docker service local IP, we can call with service name instead of service IP. so in the inner docker-machine network for connection to the mysql database or any database as docker service should be changed URL connection to docker service IP or service name
for example,
database URL connection
jdbc:mysql://your-mysql-service-name:3306/app
docker-compose declare service
version: '3.1'
services:
your-mysql-service-name:
container_name: your-mysql-service-name
image: mysql:5.6
restart: always
command: --default-authentication-plugin=mysql_native_password
deploy:
replicas: 1
ports:
- 3306:3306
environment:
MYSQL_DATABASE: "db_name"
MYSQL_ROOT_PASSWORD: "your-password"

Unable to run elasticsearch using docker-compose file

Created directory Product_dir
mkdir Product_dir
cd Product_dir
docker-compose up
Iam pointing data directory to path on my host machine : /var/elasticsearch/data/product1/
Gave full permission on directory: chmod -R 777 /var/elasticsearch/
changed owner to elasticsearch : chown -R elasticsearch:elasticsearch /var/elasticsearch/
docker-compose.yml file
version: "2"
services:
elasticsearch-5-6:
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.3
container_name: elasticsearch-5-6
ports:
- "9201:9200"
volumes:
- /var/elasticsearch/data/product1/:/usr/share/elasticsearc/data/
#- /etc/elasticsearch/elasticsearch-5-6.yml:/usr/share/elasticsearch/config/elasticsearch.yml
#- /etc/elasticsearch/logging.yml:/usr/share/elasticsearch/config/logging.yml
#- /var/log/elasticsearch/:/usr/share/elasticsearch/logs/
environment:
- cluster.name=docker-cluster-elasticsearch-5-6
#- bootstrap.memory_lock=true
- "ES_JAVA_OPTS: -Xmx2048m -Xms2048m"
Log file:
[root#localhost docker-elasticsearch-5-6]# docker-compose up
Starting elasticsearch-5-6 ...
Starting elasticsearch-5-6 ... done
Attaching to elasticsearch-5-6
elasticsearch-5-6 | [2017-11-17T01:55:09,017][INFO ][o.e.n.Node ] [] initializing ...
elasticsearch-5-6 | [2017-11-17T01:55:09,035][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
elasticsearch-5-6 | org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: Failed to create node environment
elasticsearch-5-6 | at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | Caused by: java.lang.IllegalStateException: Failed to create node environment
elasticsearch-5-6 | at org.elasticsearch.node.Node.<init>(Node.java:268) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.node.Node.<init>(Node.java:245) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:233) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:233) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | ... 6 more
elasticsearch-5-6 | Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes
elasticsearch-5-6 | at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) ~[?:?]
elasticsearch-5-6 | at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) ~[?:?]
elasticsearch-5-6 | at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) ~[?:?]
elasticsearch-5-6 | at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384) ~[?:?]
elasticsearch-5-6 | at java.nio.file.Files.createDirectory(Files.java:674) ~[?:1.8.0_141]
elasticsearch-5-6 | at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781) ~[?:1.8.0_141]
elasticsearch-5-6 | at java.nio.file.Files.createDirectories(Files.java:767) ~[?:1.8.0_141]
elasticsearch-5-6 | at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:221) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.node.Node.<init>(Node.java:265) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.node.Node.<init>(Node.java:245) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:233) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:233) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.3.jar:5.6.3]
elasticsearch-5-6 | ... 6 more
elasticsearch-5-6 exited with code 1

unable to access sonar through web

i have installed sonar on rhel 6.3 64 bit machine but when trying to access the application through web using "http://10.217.14.40:13385/sonar" i get HTTP Error 503 Service Unavailable
Following is the last 100 lines from the log
[root#RHEL-6 logs]# tail -100 sonar.log
INFO | jvm 1 | 2012/09/25 07:58:21 | 07:58:21,136 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - ROOT level set to INFO
INFO | jvm 1 | 2012/09/25 07:58:21 | 07:58:21,136 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [SONAR_FILE] to Logger[ROOT]
INFO | jvm 1 | 2012/09/25 07:58:21 | 07:58:21,136 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator#77435978 - Registering current configuration as safe fallback point
INFO | jvm 1 | 2012/09/25 07:58:21 |
2012.09.25 07:58:21 INFO o.s.s.p.ServerImpl Sonar Server / 3.2 / d9303b2d9d4c1e75f8536e4144028f1999f727f4
2012.09.25 07:58:21 INFO o.s.s.d.EmbeddedDatabase Starting embedded database on port 9092 with url jdbc:h2:tcp://10.217.14.40:13384/sonar
2012.09.25 07:58:21 ERROR o.s.s.p.Platform Unable to start database
org.sonar.api.utils.SonarException: Unable to start database
at org.sonar.server.database.EmbeddedDatabase.start(EmbeddedDatabase.java:75) ~[classes/:na]
at org.sonar.server.database.EmbeddedDatabaseFactory.start(EmbeddedDatabaseFactory.java:41) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_07]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_07]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_07]
at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_07]
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110) ~[picocontainer-2.14.1.jar:na]
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89) ~[picocontainer-2.14.1.jar:na]
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84) ~[picocontainer-2.14.1.jar:na]
at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169) ~[picocontainer-2.14.1.jar:na]
at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132) ~[picocontainer-2.14.1.jar:na]
at org.picocontainer.behaviors.Stored.start(Stored.java:110) ~[picocontainer-2.14.1.jar:na]
at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1009) ~[picocontainer-2.14.1.jar:na]
at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1002) ~[picocontainer-2.14.1.jar:na]
at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:760) ~[picocontainer-2.14.1.jar:na]
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:70) ~[sonar-plugin-api-3.2.jar:na]
at org.sonar.server.platform.Platform.startDatabaseConnectors(Platform.java:166) ~[classes/:na]
at org.sonar.server.platform.Platform.init(Platform.java:114) ~[classes/:na]
at org.sonar.server.platform.PlatformLifecycleListener.contextInitialized(PlatformLifecycleListener.java:33) [classes/:na]
at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548) [jetty-6.1.25.jar:6.1.25]
at org.mortbay.jetty.servlet.Context.startContext(Context.java:136) [jetty-6.1.25.jar:6.1.25]
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1272) [jetty-6.1.25.jar:6.1.25]
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) [jetty-6.1.25.jar:6.1.25]
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:489) [jetty-6.1.25.jar:6.1.25]
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) [jetty-util-6.1.25.jar:6.1.25]
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) [jetty-6.1.25.jar:6.1.25]
at org.mortbay.jetty.Server.doStart(Server.java:224) [jetty-6.1.25.jar:6.1.25]
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) [jetty-util-6.1.25.jar:6.1.25]
at org.sonar.application.JettyEmbedder.start(JettyEmbedder.java:72) [sonar-application-3.2.jar:na]
at org.sonar.application.StartServer.main(StartServer.java:48) [sonar-application-3.2.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_07]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_07]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_07]
at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_07]
at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240) [wrapper-3.2.3.jar:3.2.3]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0_07]
Caused by: org.h2.jdbc.JdbcSQLException: Exception opening port "9092" (port may be in use), cause: "java.net.BindException: Address already in use" [90061-167]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329) ~[h2-1.3.167.jar:1.3.167]
at org.h2.message.DbException.get(DbException.java:158) ~[h2-1.3.167.jar:1.3.167]
at org.h2.util.NetUtils.createServerSocketTry(NetUtils.java:190) ~[h2-1.3.167.jar:1.3.167]
at org.h2.util.NetUtils.createServerSocket(NetUtils.java:156) ~[h2-1.3.167.jar:1.3.167]
at org.h2.server.TcpServer.start(TcpServer.java:222) ~[h2-1.3.167.jar:1.3.167]
at org.h2.tools.Server.start(Server.java:455) ~[h2-1.3.167.jar:1.3.167]
at org.sonar.server.database.EmbeddedDatabase.start(EmbeddedDatabase.java:71) ~[classes/:na]
... 35 common frames omitted
Caused by: java.net.BindException: Address already in use
at java.net.PlainSocketImpl.socketBind(Native Method) ~[na:1.7.0_07]
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376) ~[na:1.7.0_07]
at java.net.ServerSocket.bind(ServerSocket.java:376) ~[na:1.7.0_07]
at java.net.ServerSocket.<init>(ServerSocket.java:237) ~[na:1.7.0_07]
at java.net.ServerSocket.<init>(ServerSocket.java:128) ~[na:1.7.0_07]
at org.h2.util.NetUtils.createServerSocketTry(NetUtils.java:186) ~[h2-1.3.167.jar:1.3.167]
... 39 common frames omitted
INFO | jvm 1 | 2012/09/25 07:58:21 | 2012-09-25 07:58:21.716:WARN::Failed startup of context org.mortbay.jetty.webapp.WebAppContext#1778db3{/,file:/home/BuildTools/sonar-3.2/war/sonar-server}
INFO | jvm 1 | 2012/09/25 07:58:21 | org.sonar.api.utils.SonarException: Unable to start database
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.sonar.server.database.EmbeddedDatabase.start(EmbeddedDatabase.java:75)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.sonar.server.database.EmbeddedDatabaseFactory.start(EmbeddedDatabaseFactory.java:41)
INFO | jvm 1 | 2012/09/25 07:58:21 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO | jvm 1 | 2012/09/25 07:58:21 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
INFO | jvm 1 | 2012/09/25 07:58:21 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
INFO | jvm 1 | 2012/09/25 07:58:21 | at java.lang.reflect.Method.invoke(Method.java:601)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.picocontainer.behaviors.Stored.start(Stored.java:110)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1009)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1002)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:760)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:70)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.sonar.server.platform.Platform.startDatabaseConnectors(Platform.java:166)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.sonar.server.platform.Platform.init(Platform.java:114)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.sonar.server.platform.PlatformLifecycleListener.contextInitialized(PlatformLifecycleListener.java:33)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1272)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:489)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.mortbay.jetty.Server.doStart(Server.java:224)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.sonar.application.JettyEmbedder.start(JettyEmbedder.java:72)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.sonar.application.StartServer.main(StartServer.java:48)
INFO | jvm 1 | 2012/09/25 07:58:21 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO | jvm 1 | 2012/09/25 07:58:21 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
INFO | jvm 1 | 2012/09/25 07:58:21 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
INFO | jvm 1 | 2012/09/25 07:58:21 | at java.lang.reflect.Method.invoke(Method.java:601)
INFO | jvm 1 | 2012/09/25 07:58:21 | at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
INFO | jvm 1 | 2012/09/25 07:58:21 | at java.lang.Thread.run(Thread.java:722)
INFO | jvm 1 | 2012/09/25 07:58:21 | 2012-09-25 07:58:21.737:INFO::Started SelectChannelConnector#10.217.14.40:13385
As you can read in your log, Sonar fails to start because H2 database cannot be started. It can't be started because the port 9092 is already used:
Exception opening port "9092" (port may be in use), cause: "java.net.BindException: Address already in use"
This means that you already have another process that uses this port - probably another Sonar instance that is already started...

Resources