It's my first time using any CI. I have used Travis. In current commit I added postgresql, but it is failing building (on my computer (local) it is working correctly) with stacktrace: (whole stacktrace https://travis-ci.org/must1/BookstoreScraper/builds/568424005?utm_source=github_status&utm_medium=notification)
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:280) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.Driver.makeConnection(Driver.java:454) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.Driver.connect(Driver.java:256) ~[postgresql-42.2.5.jar:42.2.5]
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:136) ~[HikariCP-3.2.0.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:369) ~[HikariCP-3.2.0.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:198) ~[HikariCP-3.2.0.jar:na]
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:467) ~[HikariCP-3.2.0.jar:na]
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:541) ~[HikariCP-3.2.0.jar:na]
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[HikariCP-3.2.0.jar:na]
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-3.2.0.jar:na]
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:151) ~[spring-jdbc-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115) ~[spring-jdbc-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78) ~[spring-jdbc-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:319) ~[spring-jdbc-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:356) ~[spring-jdbc-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.DatabaseLookup.getDatabase(DatabaseLookup.java:73) ~[spring-boot-autoconfigure-2.1.1.RELEASE.jar:2.1.1.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.JpaProperties.determineDatabase(JpaProperties.java:142) ~[spring-boot-autoconfigure-2.1.1.RELEASE.jar:2.1.1.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.jpaVendorAdapter(JpaBaseConfiguration.java:112) ~[spring-boot-autoconfigure-2.1.1.RELEASE.jar:2.1.1.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration$$EnhancerBySpringCGLIB$$314b4507.CGLIB$jpaVendorAdapter$5(<generated>) ~[spring-boot-autoconfigure-2.1.1.RELEASE.jar:2.1.1.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration$$EnhancerBySpringCGLIB$$314b4507$$FastClassBySpringCGLIB$$ae85cd83.invoke(<generated>) ~[spring-boot-autoconfigure-2.1.1.RELEASE.jar:2.1.1.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.3.RELEASE.jar:5.1.3.RELEASE]
I knwo that it cannot find postgres, but I don't know how to add it.
travis.yml configuration:
language: java
addons:
sonarcloud:
organization: "must1"
token:
secure: TOKEN # encrypted value of your token
script:
# the following command line builds the project, runs the tests with coverage and then execute the SonarCloud analysis
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar
application.properties
spring.datasource.url=jdbc:postgresql://localhost:5432/bookstore_scraper
spring.datasource.username=postgres
spring.datasource.password=1234
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults= false
There is a whole chapter in the Travis docs how to setup databases.
Especially:
https://docs.travis-ci.com/user/database-setup/#postgresql
Basically you add Postgres to the services:
services:
- postgresql
And create a database:
before_script:
- psql -c 'create database travis_ci_test;' -U postgres
If you need a specific version of Postgresql:
https://docs.travis-ci.com/user/database-setup/#using-a-different-postgresql-version
If you need Postgresql 11 - there is a little more work todo (2019-08-07):
Minimal example .travis.yml for Java:
dist: xenial
sudo: required
language: java
before_script:
- psql -c 'create database travis_ci_test' -U postgres
before_install:
- sudo apt-get update
- sudo apt-get --yes remove postgresql\*
- sudo apt-get install -y postgresql-11 postgresql-client-11
- sudo cp /etc/postgresql/{9.6,11}/main/pg_hba.conf
- sudo service postgresql restart 11
env:
global:
- PGUSER=postgres
- PGPORT=5432
script:
- psql -c "SELECT version();"
Above example can be amended for other languages - like language: node_js
Related
Im having an issue with docker-compose.
I try to implement some really basic application:
A spring boot application
Mysql
I created a Dockerfile for my springboot:
FROM maven:3.8.1-openjdk-11
FROM openjdk:11
WORKDIR /app
COPY target/app-ws.jar /app/app-ws.jar
CMD mvn clean install -DskipTests
EXPOSE 8092
# CMD ls
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=docker", "app-ws.jar"]
In my docker compose:
version: '3'
services:
# build mysql
mysqldb:
container_name: mysqldb
image: mysql:8.0.28
restart: unless-stopped
env_file:
- .env
environment:
- MYSQL_ROOT_PASSWORD:root
- MYSQL_ROOT_USER:root
- MYSQL_DATABASE:mydbname
ports:
- 3309:3309
expose:
- 3309
volumes:
- dbdata:/var/lib/mysql
networks:
- app-network
# build app-ws
app-ws:
container_name: app-ws
restart: on-failure
build:
context: ../app-ws/
dockerfile: Dockerfile
ports:
- 8092:8092
expose:
- 8092
environment:
- SPRING_DATASOURCE_URL:jdbc:mysql://mysqldb:3309/mydbname?autoReconnect=true&useSSL=false
- SPRING_DATASOURCE_USERNAME:root
- SPRING_DATASOURCE_PASSWORD:root
depends_on:
- mysqldb
links:
- mysqldb:mysqldb
networks:
- app-network
# # # Create the private network
networks:
app-network:
driver: bridge
volumes:
dbdata:
driver: local
My application-docker.properties contains the following informations:
spring.datasource.url=jdbc:mysql://mysqldb:3309/mydbname?useSSL=false
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
spring.jpa.hibernate.ddl-auto=create
spring.sql.init.mode=always
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.generate-ddl=true
I have 2 issues: When running docker compose up --build I do have the following errors concerning the springboot application:
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[na:na]
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[mysql-connector-java-8.0.28.jar!/:8.0.28]
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) ~[mysql-connector-java-8.0.28.jar!/:8.0.28]
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151) ~[mysql-connector-java-8.0.28.jar!/:8.0.28]
at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167) ~[mysql-connector-java-8.0.28.jar!/:8.0.28]
at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:89) ~[mysql-connector-java-8.0.28.jar!/:8.0.28]
at com.mysql.cj.NativeSession.connect(NativeSession.java:120) ~[mysql-connector-java-8.0.28.jar!/:8.0.28]
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:949) ~[mysql-connector-java-8.0.28.jar!/:8.0.28]
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:819) ~[mysql-connector-java-8.0.28.jar!/:8.0.28]
... 57 common frames omitted
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:na]
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412) ~[na:na]
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255) ~[na:na]
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237) ~[na:na]
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:na]
at java.base/java.net.Socket.connect(Socket.java:609) ~[na:na]
at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:156) ~[mysql-connector-java-8.0.28.jar!/:8.0.28]
at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:63) ~[mysql-connector-java-8.0.28.jar!/:8.0.28]
My second issue is that i can't connect to the database using the port 3309. I don't know what's going wrong: i use depends on to specify my app depends on mysql, i also added the environment variables with SPRING_DATASOURCE_URL, etc.
I have a Jenkins maven job and I'm getting the following error when I run the job.
Started by user admin
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/My First Maven Job
No credentials specified
> /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> /usr/bin/git config remote.origin.url https://github.com/yankils/hello-world.git # timeout=10
Fetching upstream changes from https://github.com/yankils/hello-world.git
> /usr/bin/git --version # timeout=10
> /usr/bin/git fetch --tags --force --progress -- https://github.com/yankils/hello-world.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> /usr/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> /usr/bin/git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision de043c505e7adab1f892498ca231280298fc2674 (refs/remotes/origin/master)
> /usr/bin/git config core.sparsecheckout # timeout=10
> /usr/bin/git checkout -f de043c505e7adab1f892498ca231280298fc2674 # timeout=10
Commit message: "Update Dockerfile"
> /usr/bin/git rev-list --no-walk de043c505e7adab1f892498ca231280298fc2674 # timeout=10
Parsing POMs
Established TCP socket on 34699
[My First Maven Job] $ " /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-1.el8_0.x86_64/bin/java" -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.13.jar:/opt/maven/apache-maven-3.6.3/boot/plexus-classworlds-2.6.0.jar:/opt/maven/apache-maven-3.6.3/conf/logging jenkins.maven3.agent.Maven35Main /opt/maven/apache-maven-3.6.3 /var/cache/jenkins/war/WEB-INF/lib/remoting-4.2.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.13.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.13.jar 34699
ERROR: Failed to parse POMs
java.io.IOException: Cannot run program " /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-1.el8_0.x86_64/bin/java" (in directory "/var/lib/jenkins/workspace/My First Maven Job"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:252)
at hudson.Proc$LocalProc.<init>(Proc.java:221)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:936)
at hudson.Launcher$ProcStarter.start(Launcher.java:454)
at hudson.maven.AbstractMavenProcessFactory.newProcess(AbstractMavenProcessFactory.java:280)
at hudson.maven.ProcessCache.get(ProcessCache.java:236)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:804)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1856)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:428)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 12 more
Finished: FAILURE
I can see it was looking at /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-1.el8_0.x86_64/bin where as I have openjdk /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.amzn2.0.1.x86_64/jre
How can I fix this on Jenkins server?
Set JAVA_HOME to /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.amzn2.0.1.x86_64
as opposed to /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-1.el8_0.x86_64
I have a Java Spring Boot app which works with a Postgres database. I want to use Docker for both of them. Initially, I created a docker-compose.yml file as given below:
version: '3'
services:
db:
container_name: sample_db
image: postgres
volumes:
- sample_db:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
- POSTGRES_DB="employee"
- POSTGRES_USER="user"
- POSTGRES_PASSWORD="password"
- PGDATA=/var/lib/postgresql/data/pgdata
web:
build: .
expose:
- "8080"
depends_on:
- db
volumes:
sample_db: {}
Then, in my Spring Boot app, inside the application.properties file I defined the following properties.
spring.datasource.url=jdbc:postgresql://db:5432/employee
spring.datasource.username=user
spring.datasource.password=password
along with this,I created a Dockerfile in my project directory, which looks like this:
FROM openjdk:8-jdk-alpine
EXPOSE 8080
ARG JAR_FILE=target/employee-0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE} employee-demo.jar
ENTRYPOINT ["java","-jar","employee-demo.jar"]
I issued these commands and ended up in the error as given below
mvn clean package
docker-compose up
The problem is the connection string. I believe I have to change it to something else, but I don't know what it should be. I get the following error messages:
Caused by: org.postgresql.util.PSQLException: The connection attempt failed.
web_1 | at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:292) ~[postgresql-42.2.5.jar!/:42.2.5]
web_1 | at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.5.jar!/:42.2.5]
web_1 | at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) ~[postgresql-42.2.5.jar!/:42.2.5]
web_1 | at org.postgresql.Driver.makeConnection(Driver.java:454) ~[postgresql-42.2.5.jar!/:42.2.5]
web_1 | at org.postgresql.Driver.connect(Driver.java:256) ~[postgresql-42.2.5.jar!/:42.2.5]
web_1 | at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:136) ~[HikariCP-3.2.0.jar!/:na]
web_1 | at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:369) ~[HikariCP-3.2.0.jar!/:na]
web_1 | at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:198) ~[HikariCP-3.2.0.jar!/:na]
web_1 | at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:467) ~[HikariCP-3.2.0.jar!/:na]
web_1 | at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:541) ~[HikariCP-3.2.0.jar!/:na]
web_1 | at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[HikariCP-3.2.0.jar!/:na]
web_1 | at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-3.2.0.jar!/:na]
web_1 | at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) ~[hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
web_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]
web_1 | at org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl.getIsolatedConnection(DdlTransactionIsolatorNonJtaImpl.java:43) ~[hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
web_1 | ... 44 common frames omitted
web_1 | Caused by: java.net.UnknownHostException: sample_db
web_1 | at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) ~[na:1.8.0_181]
web_1 | at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_181]
web_1 | at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_181]
web_1 | at org.postgresql.core.PGStream.<init>(PGStream.java:70) ~[postgresql-42.2.5.jar!/:42.2.5]
web_1 | at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:91) ~[postgresql-42.2.5.jar!/:42.2.5]
web_1 | at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192) ~[postgresql-42.2.5.jar!/:42.2.5]
web_1 | ... 58 common frames omitted
Am new to docker, If any issues please inform
Your service name is db, which is what you'll need to reference as the hostname from your web container. The container name, sample_db, is not resolvable from the web container because you have not specified a network, and thus are using the default bridge network.
According to the docs, the default bridge network doesn't provide name resolution between containers, only IP. Using docker compose, you should be able to resolve using the service name.
https://docs.docker.com/network/bridge/
https://docs.docker.com/compose/networking/
version: '3'
services:
db:
container_name: sample_db
image: postgres
volumes:
- sample_db:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
- POSTGRES_DB="employee"
- POSTGRES_USER="user"
- POSTGRES_PASSWORD="password"
- PGDATA=/var/lib/postgresql/data/pgdata
networks:
- my_network
web:
build: .
expose:
- "8080"
depends_on:
- db
networks:
- my_network
volumes:
sample_db: {}
networks:
my_network:
driver: bridge
A link should also work instead of defining your own custom bridge network:
web:
build: .
expose:
- "8080"
depends_on:
- db
links:
- "db:sample_db"
It was because of the " " given mistakenly. I changed it to
version: '3'
services:
db:
restart: always
image: postgres
ports:
- "5432:5432"
environment:
- POSTGRES_DB=employee
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
web:
build: .
ports:
- 8080:8080
Now it is working fine. Thank you for your valuable time.
I am using docker compose to run a sbt process which connect to rabbitmq-server . Following is my docker compose file : -
version: "3"
services:
web:
# replace username/repo:tag with your name and image details
image: abhishekkumargaya/messanger
ports:
- "1883:1883"
links:
- rabbit-server
- redis
- mysql
networks:
- webnet
rabbit-server:
image: "rabbitmq:3-management"
hostname: localhost
environment:
#RABBITMQ_ERLANG_COOKIE: "SWQOKODSQALRPCLNMEQG"
RABBITMQ_DEFAULT_USER : guest
RABBITMQ_DEFAULT_PASS : guest
ports:
- "5672:5672"
- "15672:15672"
networks:
- webnet
redis:
image: "redis:alpine"
mysql:
image: mysql
container_name: database.dev
command: mysqld --user=root --verbose
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: "user_messages"
MYSQL_USER: "test"
MYSQL_PASSWORD: "root"
MYSQL_ROOT_PASSWORD: "root"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
networks:
webnet:
volumes:
redis-data:
I am getting connection refused error. I am using default value to connect to rabbit server in my code .
private lazy val factory = new ConnectionFactory
val connection = factory.newConnection()
My docker file : -
FROM openjdk:8
ENV SBT_VERSION 0.13.16
RUN \
curl -L -o sbt-$SBT_VERSION.deb http://dl.bintray.com/sbt/debian/sbt-$SBT_VERSION.deb && \
dpkg -i sbt-$SBT_VERSION.deb && \
rm sbt-$SBT_VERSION.deb && \
apt-get update && \
apt-get install sbt && \
sbt sbtVersion
WORKDIR /app
ADD target/scala-2.11/messanger-assembly-1.0.jar /app
EXPOSE 1883
CMD java -jar messanger-assembly-1.0.jar
The error which I am getting is as follows :-
Caused by: java.net.ConnectException: Connection refused (Connection refused)
web_1 | at java.net.PlainSocketImpl.socketConnect(Native Method)
web_1 | at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
web_1 | at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
web_1 | at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
web_1 | at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
web_1 | at java.net.Socket.connect(Socket.java:589)
web_1 | at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:60)
web_1 | at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:62)
web_1 | at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:99)
web_1 | at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:948)
web_1 | at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:907)
web_1 | at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:865)
web_1 | at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1018)
web_1 | at com.abhishek.rabbitmq.RabbitMqConnectionFactory$.<init>(RabbitMqConnectionFactory.scala:15)
web_1 | at com.abhishek.rabbitmq.RabbitMqConnectionFactory$.<clinit>(RabbitMqConnectionFactory.scala)
I am not properly understanding how these variable works :-
hostname: localhost
environment:
#RABBITMQ_ERLANG_COOKIE: "SWQOKODSQALRPCLNMEQG"
- RABBITMQ_DEFAULT_USER = guest
- RABBITMQ_DEFAULT_PASS = guest
I kept this variable like this because by default my client is using host as localhost , user as guest and password as guest to connect to rabbitmq-server
If I am just running rabbitmq-server image with command -
docker-compose up --build
I am able to connect it through my localmachine .
I am able to connect now. To connect to rabbit container, I need to put host as rabbit in my web container.Similarily for connection to mysql and redis , I need to use host as mysql and redis respectively.
You can depend on localhost if you set network_mode for your web to "host"
gradle build fails in my DEV environment. My colleagues have the same configuration as that of mine but it works fine for them. Also, I was able to execute the build command successfully last week.
Environment configuration:
Gradle 2.3
Groovy: 2.3.9
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_73 (Oracle Corporation 25.73-b02)
OS: Linux 2.6.32-300.3.1.el6uek.x86_64 amd64
Task:
task updateLibraries {
delete "lib/compile"
delete "lib/test"
// error at the line below
copy {
from configurations.compile.copy()
into( 'lib/compile' )
}
copy {
from configurations.testCompile.copy()
into( 'lib/test' )
}
}
Error:
FAILURE: Build failed with an exception.
Where:
Build file '/home/user/ProjectName/build.gradle' line: 303
What went wrong:
A problem occurred evaluating root project 'ProjectName'.
net.rubygrapefruit.platform.internal.jni.PosixFileFunctions.stat(Ljava/lang/String;Lnet/rubygrapefruit/platform/internal/FileStat;Lnet/rubygrapefruit/platform/internal/FunctionResult;)V
Try:
Run with --info or --debug option to get more log output.
Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'ProjectName'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:154)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:59)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:492)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:86)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.UnsatisfiedLinkError: net.rubygrapefruit.platform.internal.jni.PosixFileFunctions.stat(Ljava/lang/String;Lnet/rubygrapefruit/platform/internal/FileStat;Lnet/rubygrapefruit/platform/internal/FunctionResult;)V
at net.rubygrapefruit.platform.internal.jni.PosixFileFunctions.stat(Native Method)
at net.rubygrapefruit.platform.internal.DefaultPosixFiles.stat(DefaultPosixFiles.java:30)
at net.rubygrapefruit.platform.internal.DefaultPosixFiles.getMode(DefaultPosixFiles.java:46)
at org.gradle.internal.nativeintegration.filesystem.services.NativePlatformBackedStat.getUnixMode(NativePlatformBackedStat.java:33)
at org.gradle.internal.nativeintegration.filesystem.services.GenericFileSystem.getUnixMode(GenericFileSystem.java:61)
at org.gradle.api.internal.file.DefaultFileTreeElement.getMode(DefaultFileTreeElement.java:67)
at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:76)
at org.gradle.api.internal.file.copy.DefaultFileCopyDetails.copyTo(DefaultFileCopyDetails.java:104)
at org.gradle.api.internal.file.copy.FileCopyAction$FileCopyDetailsInternalAction.processFile(FileCopyAction.java:44)
at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator$1$1.processFile(NormalizingCopyActionDecorator.java:65)
at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator$1$1.processFile(DuplicateHandlingCopyActionDecorator.java:60)
at org.gradle.api.internal.file.copy.CopyFileVisitorImpl.processFile(CopyFileVisitorImpl.java:60)
at org.gradle.api.internal.file.copy.CopyFileVisitorImpl.visitFile(CopyFileVisitorImpl.java:44)
at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTree$1.visitFile(AbstractFileTree.java:145)
at org.gradle.api.internal.file.collections.SingletonFileTree.visit(SingletonFileTree.java:43)
at org.gradle.api.internal.file.collections.FileTreeAdapter.visit(FileTreeAdapter.java:96)
at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTree.visit(AbstractFileTree.java:136)
at org.gradle.api.internal.file.CompositeFileTree.visit(CompositeFileTree.java:54)
at org.gradle.api.internal.file.copy.CopySpecActionImpl.execute(CopySpecActionImpl.java:37)
at org.gradle.api.internal.file.copy.CopySpecActionImpl.execute(CopySpecActionImpl.java:24)
at org.gradle.api.internal.file.copy.DefaultCopySpec$DefaultCopySpecResolver.walk(DefaultCopySpec.java:498)
at org.gradle.api.internal.file.copy.DefaultCopySpec.walk(DefaultCopySpec.java:322)
at org.gradle.api.internal.file.copy.DelegatingCopySpecInternal.walk(DelegatingCopySpecInternal.java:206)
at org.gradle.api.internal.file.copy.CopySpecBackedCopyActionProcessingStream.process(CopySpecBackedCopyActionProcessingStream.java:36)
at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator$1.process(DuplicateHandlingCopyActionDecorator.java:44)
at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator$1.process(NormalizingCopyActionDecorator.java:56)
at org.gradle.api.internal.file.copy.FileCopyAction.execute(FileCopyAction.java:35)
at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator.execute(NormalizingCopyActionDecorator.java:52)
at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator.execute(DuplicateHandlingCopyActionDecorator.java:42)
at org.gradle.api.internal.file.copy.CopyActionExecuter.execute(CopyActionExecuter.java:38)
at org.gradle.api.internal.file.copy.FileCopier.doCopy(FileCopier.java:64)
at org.gradle.api.internal.file.copy.FileCopier.copy(FileCopier.java:49)
at org.gradle.api.internal.file.DefaultFileOperations.copy(DefaultFileOperations.java:125)
at org.gradle.api.internal.project.AbstractProject.copy(AbstractProject.java:746)
at org.gradle.groovy.scripts.DefaultScript.copy(DefaultScript.java:169)
at org.gradle.groovy.scripts.DefaultScript.copy(DefaultScript.java:165)
at build_3o7k207plxbmxd2hy7hl6sbsq$runclosure22.doCall(/home/user/ProjectName/build.gradle:303)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:67)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:110)
at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:488)
at org.gradle.api.internal.project.AbstractProject.task(AbstractProject.java:851)
at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:225)
at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:129)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
at build_3o7k207plxbmxd2hy7hl6sbsq.run(/home/user/ProjectName/build.gradle:299)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
... 32 more
BUILD FAILED
Sounds like a standard library needed by the JNI libraries is not installed on your machine (hard to believe).
cd /tmp
unzip ${your_gradle_home}/lib/native-platform-linux-amd64-0.10.jar
cd net/rubygrapefruit/platform/linux-amd64
ldd -v libnative-platform.so
Check if one of the libraries is not installed/found.
For each dependency (on the left) there should be a valid reference on the right
either: linux-vdso.so.1 => (0x00007ffe209dc000)
or : libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f1206b7e000)
if you see something like (for example)
libstdc++.so.6 => not found
it means you need to install the package (of your Linux distribution) which provide the libstdc++.so.6.